diff --git a/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/FailoverPhoenixConnection.java b/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/FailoverPhoenixConnection.java index 0ad691958fc..307a3948dd5 100644 --- a/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/FailoverPhoenixConnection.java +++ b/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/FailoverPhoenixConnection.java @@ -17,16 +17,30 @@ */ package org.apache.phoenix.jdbc; +import org.apache.hadoop.hbase.client.Consistency; import org.apache.phoenix.exception.FailoverSQLException; import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.execute.MutationState; +import org.apache.phoenix.hbase.index.util.KeyValueBuilder; +import org.apache.phoenix.log.LogLevel; import org.apache.phoenix.monitoring.MetricType; +import org.apache.phoenix.query.ConnectionQueryServices; +import org.apache.phoenix.schema.PMetaData; +import org.apache.phoenix.schema.PName; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.PTableKey; +import org.apache.phoenix.schema.types.PDataType; import org.apache.phoenix.thirdparty.com.google.common.annotations.VisibleForTesting; import org.apache.phoenix.thirdparty.com.google.common.base.Preconditions; import org.apache.phoenix.util.EnvironmentEdgeManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.annotation.Nullable; +import java.io.IOException; +import java.io.PrintStream; +import java.io.Reader; import java.sql.Array; import java.sql.Blob; import java.sql.CallableStatement; @@ -41,7 +55,9 @@ import java.sql.Savepoint; import java.sql.Statement; import java.sql.Struct; +import java.text.Format; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Properties; import java.util.concurrent.Executor; @@ -372,6 +388,37 @@ public PreparedStatement prepareStatement(String sql) throws SQLException { return wrapActionDuringFailover(() -> connection.prepareStatement(sql)); } + @Override + public String getDatePattern() throws SQLException { + return wrapActionDuringFailover(() -> connection.getDatePattern()); + } + + @Override + public PTable getTable(@Nullable String tenantId, String fullTableName, @Nullable Long timestamp) throws SQLException { + return wrapActionDuringFailover(() -> connection.getTable(tenantId, fullTableName, timestamp)); + } + + @Override + public boolean isRunningUpgrade() throws SQLException { + return wrapActionDuringFailover(() -> connection.isRunningUpgrade()); + } + + @Override + public String getURL() throws SQLException { + return wrapActionDuringFailover(() -> connection.getURL()); + } + + @Override + public LogLevel getLogLevel() throws SQLException { + return wrapActionDuringFailover(() -> connection.getLogLevel()); + } + + @Override + public KeyValueBuilder getKeyValueBuilder() throws SQLException { + return wrapActionDuringFailover(() -> connection.getKeyValueBuilder()); + } + + @Override public CallableStatement prepareCall(String sql) throws SQLException { return wrapActionDuringFailover(() -> connection.prepareCall(sql)); @@ -623,6 +670,88 @@ public int getNetworkTimeout() throws SQLException { return wrapActionDuringFailover(() -> connection.getNetworkTimeout()); } + @Override + public ConnectionQueryServices getQueryServices() throws SQLException { + return wrapActionDuringFailover(() -> connection.getQueryServices()); + } + + @Override + public PTable getTable(PTableKey key) throws SQLException { + return wrapActionDuringFailover(() -> connection.getTable(key)); + } + + @Override + public PTable getTable(String name) throws SQLException { + return wrapActionDuringFailover(() -> connection.getTable(name)); + } + + @Override + public PTable getTableNoCache(String name) throws SQLException { + return wrapActionDuringFailover(() -> connection.getTableNoCache(name)); + } + + @Override + public Consistency getConsistency() throws SQLException { + return wrapActionDuringFailover(() -> connection.getConsistency()); + } + + @Override + @Nullable + public PName getTenantId() throws SQLException { + return wrapActionDuringFailover(() -> connection.getTenantId()); + } + + @Override + public MutationState getMutationState() throws SQLException { + return wrapActionDuringFailover(() -> connection.getMutationState()); + } + + @Override + public PMetaData getMetaDataCache() throws SQLException { + return wrapActionDuringFailover(() -> connection.getMetaDataCache()); + } + + @Override + public int getMutateBatchSize() throws SQLException { + return wrapActionDuringFailover(() -> connection.getMutateBatchSize()); + } + + @Override + public int executeStatements(Reader reader, List binds, PrintStream out) throws IOException, SQLException { + return wrapActionDuringFailover(() -> { + try { + return connection.executeStatements(reader,binds,out); + } catch (IOException e) { + throw new RuntimeException(e); + } + }); + } + + @Override + public Format getFormatter(PDataType type) throws SQLException { + return wrapActionDuringFailover(() -> connection.getFormatter(type)); + } + + @Override + public void setRunningUpgrade(boolean isRunningUpgrade) throws SQLException { + wrapActionDuringFailover(() -> connection.setRunningUpgrade(isRunningUpgrade)); + } + + @Override + public PTable getTable(String tenantId, String fullTableName) throws SQLException { + return wrapActionDuringFailover(() -> connection.getTable(tenantId, fullTableName)); + } + + @Override + public PTable getTableNoCache(PName tenantId, String name) throws SQLException { + return wrapActionDuringFailover(() -> connection.getTableNoCache(tenantId, name)); + } + + @Override + public void setIsClosing(boolean imitateIsClosing) throws SQLException { + wrapActionDuringFailover(() -> connection.setIsClosing(imitateIsClosing)); + } + /** * @return the currently wrapped connection. */ diff --git a/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/HighAvailabilityGroup.java b/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/HighAvailabilityGroup.java index 9b704973c4a..898660abf55 100644 --- a/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/HighAvailabilityGroup.java +++ b/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/HighAvailabilityGroup.java @@ -124,7 +124,7 @@ public class HighAvailabilityGroup { public static final String PHOENIX_HA_TRANSITION_TIMEOUT_MS_KEY = PHOENIX_HA_ATTR_PREFIX + "transition.timeout.ms"; public static final long PHOENIX_HA_TRANSITION_TIMEOUT_MS_DEFAULT = 5 * 60 * 1000; // 5 mins - + public static final String HA_GROUP_PROFILE = "phoenix.ha.profile.active"; static final Logger LOG = LoggerFactory.getLogger(HighAvailabilityGroup.class); /** @@ -731,7 +731,7 @@ HAGroupInfo getGroupInfo() { return info; } - Properties getProperties() { + public Properties getProperties() { return properties; } @@ -748,7 +748,7 @@ public ClusterRoleRecord getRoleRecord() { * The lifecycle management is confined to this class because an HA group is a shared resource. * Someone calling close on this would make it unusable, since the state would become closed. */ - void close() { + public void close() { roleManagerExecutor.shutdownNow(); try { // TODO: Parameterize and set in future work item for pluggable diff --git a/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/ParallelPhoenixConnection.java b/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/ParallelPhoenixConnection.java index 9ac38cbd8d8..70ff274e103 100644 --- a/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/ParallelPhoenixConnection.java +++ b/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/ParallelPhoenixConnection.java @@ -17,15 +17,29 @@ */ package org.apache.phoenix.jdbc; +import org.apache.hadoop.hbase.client.Consistency; import org.apache.hadoop.hbase.util.PairOfSameType; import org.apache.phoenix.exception.SQLExceptionInfo; +import org.apache.phoenix.execute.MutationState; +import org.apache.phoenix.hbase.index.util.KeyValueBuilder; import org.apache.phoenix.jdbc.ParallelPhoenixUtil.FutureResult; +import org.apache.phoenix.log.LogLevel; import org.apache.phoenix.monitoring.MetricType; +import org.apache.phoenix.query.ConnectionQueryServices; +import org.apache.phoenix.schema.PMetaData; +import org.apache.phoenix.schema.PName; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.PTableKey; +import org.apache.phoenix.schema.types.PDataType; import org.apache.phoenix.thirdparty.com.google.common.annotations.VisibleForTesting; import org.apache.phoenix.thirdparty.com.google.common.base.Preconditions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.annotation.Nullable; +import java.io.IOException; +import java.io.PrintStream; +import java.io.Reader; import java.sql.Array; import java.sql.Blob; import java.sql.CallableStatement; @@ -41,6 +55,7 @@ import java.sql.Savepoint; import java.sql.Statement; import java.sql.Struct; +import java.text.Format; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -679,4 +694,206 @@ public void clearMetrics() { } context.resetMetrics(); } + + @Override + public ConnectionQueryServices getQueryServices() throws SQLException { + Function function = (T) -> { + return T.getQueryServices(); + }; + return (ConnectionQueryServices) runOnConnections(function, true); + + } + + @Override + public PTable getTable(PTableKey key) throws SQLException { + Function function = (T) -> { + try { + return T.getTable(key); + } catch (SQLException exception) { + throw new CompletionException(exception); + } + }; + return (PTable) runOnConnections(function, true); + + } + + @Override + public PTable getTable(String name) throws SQLException { + Function function = (T) -> { + try { + return T.getTable(name); + } catch (SQLException exception) { + throw new CompletionException(exception); + } + }; + return (PTable) runOnConnections(function, true); + } + + @Override + public PTable getTableNoCache(String name) throws SQLException { + Function function = (T) -> { + try { + return T.getTableNoCache(name); + } catch (SQLException exception) { + throw new CompletionException(exception); + } + }; + return (PTable) runOnConnections(function, true); + } + + @Override + public Consistency getConsistency() throws SQLException { + Function function = (T) -> { + return T.getConsistency(); + }; + return (Consistency) runOnConnections(function, true); + } + + @Override + @Nullable + public PName getTenantId() throws SQLException { + Function function = (T) -> { + return T.getTenantId(); + }; + return (PName) runOnConnections(function, true); + } + + @Override + public MutationState getMutationState() throws SQLException { + Function function = (T) -> { + return T.getMutationState(); + }; + return (MutationState) runOnConnections(function, true); + } + + @Override + public PMetaData getMetaDataCache() throws SQLException { + Function function = (T) -> { + return T.getMetaDataCache(); + }; + return (PMetaData) runOnConnections(function, true); + } + + @Override + public int getMutateBatchSize() throws SQLException { + Function function = (T) -> { + return T.getMutateBatchSize(); + }; + return (int) runOnConnections(function, true); + } + + @Override + public int executeStatements(Reader reader, List binds, PrintStream out) throws IOException, SQLException { + Function function = (T) -> { + try { + return T.executeStatements(reader,binds,out); + } catch (SQLException exception) { + throw new CompletionException(exception); + } catch (IOException e) { + throw new RuntimeException(e); + } + }; + return (int) runOnConnections(function, true); + } + + @Override + public Format getFormatter(PDataType type) throws SQLException { + Function function = (T) -> { + return T.getFormatter(type); + }; + return (Format) runOnConnections(function, true); + } + + @Override + public void setRunningUpgrade(boolean isRunningUpgrade) throws SQLException { + Function function = (T) -> { + T.setRunningUpgrade(isRunningUpgrade); + return null; + }; + runOnConnections(function, true); + } + + @Override + public PTable getTable(String tenantId, String fullTableName) throws SQLException { + Function function = (T) -> { + try { + return T.getTable(tenantId, fullTableName); + } catch (SQLException exception) { + throw new CompletionException(exception); + } + }; + return (PTable) runOnConnections(function, true); + } + + @Override + public PTable getTableNoCache(PName tenantId, String name) throws SQLException { + Function function = (T) -> { + try { + return T.getTableNoCache(tenantId, name); + } catch (SQLException exception) { + throw new CompletionException(exception); + } + }; + return (PTable) runOnConnections(function, true); + } + + @Override + public void setIsClosing(boolean imitateIsClosing) throws SQLException { + Function function = (T) -> { + T.setIsClosing(imitateIsClosing); + return null; + }; + runOnConnections(function, true); } + + @Override + public String getDatePattern() throws SQLException { + Function function = (T) -> { + return T.getDatePattern(); + }; + return (String) runOnConnections(function, true); + } + + @Override + public PTable getTable(@Nullable String tenantId, String fullTableName, @Nullable Long timestamp) throws SQLException { + Function function = (T) -> { + try { + return T.getTable(tenantId, fullTableName, timestamp); + } catch (SQLException exception) { + throw new CompletionException(exception); + } + }; + return (PTable) runOnConnections(function, true); + } + + @Override + public boolean isRunningUpgrade() throws SQLException { + Function function = (T) -> { + return T.isRunningUpgrade(); + }; + return (boolean) runOnConnections(function, true); + } + + @Override + public String getURL() throws SQLException { + Function function = (T) -> { + return T.getURL(); + }; + return (String) runOnConnections(function, true); + } + + @Override + public LogLevel getLogLevel() throws SQLException { + Function function = (T) -> { + return T.getLogLevel(); + }; + return (LogLevel) runOnConnections(function, true); + } + + @Override + public KeyValueBuilder getKeyValueBuilder() throws SQLException { + Function function = (T) -> { + return T.getKeyValueBuilder(); + }; + return (KeyValueBuilder) runOnConnections(function, true); + } } diff --git a/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/PhoenixMonitoredConnection.java b/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/PhoenixMonitoredConnection.java index d017f7bbcc8..800b36cf19f 100644 --- a/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/PhoenixMonitoredConnection.java +++ b/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/PhoenixMonitoredConnection.java @@ -18,9 +18,27 @@ package org.apache.phoenix.jdbc; +import org.apache.hadoop.hbase.client.Consistency; +import org.apache.phoenix.execute.MutationState; +import org.apache.phoenix.hbase.index.util.KeyValueBuilder; +import org.apache.phoenix.log.LogLevel; import org.apache.phoenix.monitoring.MetricType; +import org.apache.phoenix.query.ConnectionQueryServices; +import org.apache.phoenix.schema.PMetaData; +import org.apache.phoenix.schema.PName; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.PTableKey; +import org.apache.phoenix.schema.types.PDataType; +import javax.annotation.Nullable; +import java.io.IOException; +import java.io.PrintStream; +import java.io.Reader; import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.text.Format; +import java.util.List; import java.util.Map; /** @@ -47,5 +65,30 @@ public interface PhoenixMonitoredConnection extends Connection { * metrics for individual DML. */ void clearMetrics(); + ConnectionQueryServices getQueryServices() throws SQLException; + PTable getTable(PTableKey key) throws SQLException; + PTable getTable(String name) throws SQLException; + PTable getTableNoCache(String name) throws SQLException; + Consistency getConsistency() throws SQLException; + PName getTenantId() throws SQLException; + MutationState getMutationState() throws SQLException; + PMetaData getMetaDataCache() throws SQLException; + int getMutateBatchSize() throws SQLException; + int executeStatements(Reader reader, List binds, + PrintStream out) throws IOException, SQLException; + Format getFormatter(PDataType type) throws SQLException; + void setRunningUpgrade(boolean isRunningUpgrade) throws SQLException; + PTable getTable(String tenantId, String fullTableName) + throws SQLException; + PTable getTableNoCache(PName tenantId, String name) throws SQLException; + void setIsClosing(boolean imitateIsClosing) throws SQLException; + PreparedStatement prepareStatement(String sql) throws SQLException; + String getDatePattern() throws SQLException; + PTable getTable(@Nullable String tenantId, String fullTableName, + @Nullable Long timestamp) throws SQLException; + boolean isRunningUpgrade() throws SQLException; + String getURL() throws SQLException; + LogLevel getLogLevel() throws SQLException; + KeyValueBuilder getKeyValueBuilder() throws SQLException; } diff --git a/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java b/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java index a224a111566..891b1f683b2 100644 --- a/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java +++ b/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java @@ -617,7 +617,7 @@ public Pair call() throws SQLException { final long startExecuteMutationTime = EnvironmentEdgeManager.currentTimeMillis(); clearResultSet(); try { - PhoenixConnection conn = getConnection(); + PhoenixMonitoredConnection conn = getConnection(); if (conn.getQueryServices().isUpgradeRequired() && !conn.isRunningUpgrade() && stmt.getOperation() != Operation.UPGRADE) { throw new UpgradeRequiredException(); diff --git a/phoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java b/phoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java index b2c7f3b4e3d..f76e614956b 100644 --- a/phoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java +++ b/phoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java @@ -3795,7 +3795,7 @@ private void copyDataFromPhoenixTTLtoTTL(PhoenixConnection oldMetaConnection) th } - private void moveTTLFromHBaseLevelTTLToPhoenixLevelTTL(PhoenixConnection oldMetaConnection) throws IOException { + private void moveTTLFromHBaseLevelTTLToPhoenixLevelTTL(PhoenixConnection oldMetaConnection) throws IOException, SQLException { // Increase the timeouts so that the scan queries during Copy Data does not timeout // on large SYSCAT Tables Map options = new HashMap<>(); diff --git a/phoenix-core-client/src/main/java/org/apache/phoenix/util/CSVCommonsLoader.java b/phoenix-core-client/src/main/java/org/apache/phoenix/util/CSVCommonsLoader.java index 835aea6ddd4..2c42798d6af 100644 --- a/phoenix-core-client/src/main/java/org/apache/phoenix/util/CSVCommonsLoader.java +++ b/phoenix-core-client/src/main/java/org/apache/phoenix/util/CSVCommonsLoader.java @@ -28,6 +28,7 @@ import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.util.csv.CsvUpsertExecutor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -59,7 +60,7 @@ public class CSVCommonsLoader { .put('9', '\u0009') .build(); - private final PhoenixConnection conn; + private final PhoenixMonitoredConnection conn; private final String tableName; private final List columns; private final boolean isStrict; @@ -78,12 +79,12 @@ public enum PhoenixHeaderSource { SUPPLIED_BY_USER } - public CSVCommonsLoader(PhoenixConnection conn, String tableName, - List columns, boolean isStrict) { + public CSVCommonsLoader(PhoenixMonitoredConnection conn, String tableName, + List columns, boolean isStrict) { this(conn, tableName, columns, isStrict, ',', '"', null, DEFAULT_ARRAY_ELEMENT_SEPARATOR); } - public CSVCommonsLoader(PhoenixConnection conn, String tableName, + public CSVCommonsLoader(PhoenixMonitoredConnection conn, String tableName, List columns, boolean isStrict, char fieldDelimiter, char quoteCharacter, Character escapeCharacter, String arrayElementSeparator) { this.conn = conn; @@ -255,12 +256,12 @@ private List buildColumnInfoList(CSVParser parser) throws SQLExcepti static class CsvUpsertListener implements UpsertExecutor.UpsertListener { - private final PhoenixConnection conn; + private final PhoenixMonitoredConnection conn; private final int upsertBatchSize; private long totalUpserts = 0L; private final boolean strict; - CsvUpsertListener(PhoenixConnection conn, int upsertBatchSize, boolean strict) { + CsvUpsertListener(PhoenixMonitoredConnection conn, int upsertBatchSize, boolean strict) { this.conn = conn; this.upsertBatchSize = upsertBatchSize; this.strict = strict; diff --git a/phoenix-core-client/src/main/java/org/apache/phoenix/util/IndexUtil.java b/phoenix-core-client/src/main/java/org/apache/phoenix/util/IndexUtil.java index 01762600ab5..6f1cb40be12 100644 --- a/phoenix-core-client/src/main/java/org/apache/phoenix/util/IndexUtil.java +++ b/phoenix-core-client/src/main/java/org/apache/phoenix/util/IndexUtil.java @@ -55,6 +55,7 @@ import org.apache.hadoop.hbase.client.TableDescriptorBuilder; import org.apache.phoenix.coprocessorclient.BaseScannerRegionObserverConstants; import org.apache.phoenix.index.PhoenixIndexCodec; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.thirdparty.com.google.common.cache.Cache; import org.apache.phoenix.thirdparty.com.google.common.cache.CacheBuilder; @@ -693,12 +694,12 @@ public static boolean isLocalIndexFamily(String family) { return family.indexOf(LOCAL_INDEX_COLUMN_FAMILY_PREFIX) != -1; } - public static void updateIndexState(PhoenixConnection conn, String indexTableName, - PIndexState newState, Long indexDisableTimestamp) throws SQLException { + public static void updateIndexState(PhoenixMonitoredConnection conn, String indexTableName, + PIndexState newState, Long indexDisableTimestamp) throws SQLException { updateIndexState(conn, indexTableName, newState, indexDisableTimestamp, HConstants.LATEST_TIMESTAMP); } - public static void updateIndexState(PhoenixConnection conn, String indexTableName, + public static void updateIndexState(PhoenixMonitoredConnection conn, String indexTableName, PIndexState newState, Long indexDisableTimestamp, Long expectedMaxTimestamp) throws SQLException { byte[] indexTableKey = SchemaUtil.getTableKeyFromFullName(indexTableName); String schemaName = SchemaUtil.getSchemaNameFromFullName(indexTableName); diff --git a/phoenix-core-client/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java b/phoenix-core-client/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java index b5f98ce457f..8f87d6480a0 100644 --- a/phoenix-core-client/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java +++ b/phoenix-core-client/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java @@ -414,7 +414,7 @@ public static final String[] getConnectionProperties() { * @throws SQLException */ public static int executeStatements(Connection conn, Reader reader, List binds) throws IOException,SQLException { - PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pconn = conn.unwrap(PhoenixMonitoredConnection.class); // Turn auto commit to true when running scripts in case there's DML pconn.setAutoCommit(true); return pconn.executeStatements(reader, binds, System.out); @@ -455,7 +455,7 @@ public static Iterator>> getUncommittedDataIterator(Conne * @throws SQLException */ public static Iterator>> getUncommittedDataIterator(Connection conn, boolean includeMutableIndexes) throws SQLException { - final PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); + final PhoenixMonitoredConnection pconn = conn.unwrap(PhoenixMonitoredConnection.class); final Iterator>> iterator = pconn.getMutationState().toMutations(includeMutableIndexes); return new Iterator>>() { @@ -475,7 +475,11 @@ public Pair> next() { } } } - Collections.sort(keyValues, pconn.getKeyValueBuilder().getKeyValueComparator()); + try { + Collections.sort(keyValues, pconn.getKeyValueBuilder().getKeyValueComparator()); + } catch (SQLException e) { + throw new RuntimeException(e); + } return new Pair>(pair.getFirst(),keyValues); } @@ -488,7 +492,7 @@ public void remove() { } public static PTable getTableNoCache(Connection conn, String name) throws SQLException { - PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pconn = conn.unwrap(PhoenixMonitoredConnection.class); return pconn.getTableNoCache(name); } @@ -506,7 +510,7 @@ public static PTable getTableNoCache(Connection conn, String name) throws SQLExc * @throws SQLException */ public static PTable getTable(Connection conn, String name) throws SQLException { - PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pconn = conn.unwrap(PhoenixMonitoredConnection.class); return pconn.getTable(name); } diff --git a/phoenix-core-client/src/main/java/org/apache/phoenix/util/QueryUtil.java b/phoenix-core-client/src/main/java/org/apache/phoenix/util/QueryUtil.java index 6edb67af11d..3e9fbc71ea5 100644 --- a/phoenix-core-client/src/main/java/org/apache/phoenix/util/QueryUtil.java +++ b/phoenix-core-client/src/main/java/org/apache/phoenix/util/QueryUtil.java @@ -86,6 +86,7 @@ import org.apache.phoenix.iterate.ResultIterator; import org.apache.phoenix.jdbc.ConnectionInfo; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.parse.HintNode; import org.apache.phoenix.parse.HintNode.Hint; import org.apache.phoenix.parse.TableName; @@ -408,7 +409,7 @@ public static Connection getConnectionOnServer(Properties props, Configuration c throws SQLException { setServerConnection(props); Connection conn = getConnection(props, conf); - conn.unwrap(PhoenixConnection.class).getQueryServices().clearUpgradeRequired(); + conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().clearUpgradeRequired(); return conn; } diff --git a/phoenix-core-client/src/main/java/org/apache/phoenix/util/ReadOnlyProps.java b/phoenix-core-client/src/main/java/org/apache/phoenix/util/ReadOnlyProps.java index 9b9de68bfd8..2ec2b6728e2 100644 --- a/phoenix-core-client/src/main/java/org/apache/phoenix/util/ReadOnlyProps.java +++ b/phoenix-core-client/src/main/java/org/apache/phoenix/util/ReadOnlyProps.java @@ -65,7 +65,7 @@ public ReadOnlyProps(Iterator> iterator) { this(EMPTY_PROPS, iterator); } - private ReadOnlyProps() { + public ReadOnlyProps() { this.props = ImmutableMap.of(); this.overrideProps = ImmutableMap.of(); } diff --git a/phoenix-core-client/src/main/java/org/apache/phoenix/util/ScanUtil.java b/phoenix-core-client/src/main/java/org/apache/phoenix/util/ScanUtil.java index 1941692f573..42a289bce80 100644 --- a/phoenix-core-client/src/main/java/org/apache/phoenix/util/ScanUtil.java +++ b/phoenix-core-client/src/main/java/org/apache/phoenix/util/ScanUtil.java @@ -92,6 +92,7 @@ import org.apache.phoenix.index.IndexMaintainer; import org.apache.phoenix.index.PhoenixIndexCodec; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.KeyRange; import org.apache.phoenix.query.KeyRange.Bound; import org.apache.phoenix.query.QueryConstants; @@ -1117,7 +1118,7 @@ public static boolean isServerSideMaskingEnabled(PhoenixConnection phoenixConnec ((isServerSideMaskingSet != null) && (Boolean.parseBoolean(isServerSideMaskingSet)))); } - public static boolean getStatsForParallelizationProp(PhoenixConnection conn, PTable table) + public static boolean getStatsForParallelizationProp(PhoenixMonitoredConnection conn, PTable table) throws SQLException { Boolean useStats = table.useStatsForParallelization(); if (useStats != null) { diff --git a/phoenix-core-client/src/main/java/org/apache/phoenix/util/ViewUtil.java b/phoenix-core-client/src/main/java/org/apache/phoenix/util/ViewUtil.java index 924ce278290..effd7954d9b 100644 --- a/phoenix-core-client/src/main/java/org/apache/phoenix/util/ViewUtil.java +++ b/phoenix-core-client/src/main/java/org/apache/phoenix/util/ViewUtil.java @@ -19,6 +19,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.hadoop.hbase.CompareOperator; import org.apache.phoenix.coprocessorclient.MetaDataEndpointImplConstants; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.schema.types.PSmallint; import org.apache.phoenix.thirdparty.com.google.common.base.Objects; import org.apache.phoenix.thirdparty.com.google.common.base.Preconditions; @@ -685,7 +686,7 @@ public static PTable addDerivedColumnsAndIndexesFromParent(PhoenixConnection con * PHOENIX-3534) we choose the child column over the parent column * @return table with inherited columns */ - public static PTable addDerivedColumnsFromParent(PhoenixConnection connection, + public static PTable addDerivedColumnsFromParent(PhoenixMonitoredConnection connection, PTable view, PTable parentTable) throws SQLException { return addDerivedColumnsFromParent(connection, view, parentTable, true); @@ -696,7 +697,7 @@ public static PTable addDerivedColumnsFromParent(PhoenixConnection connection, * PHOENIX-3534) we choose the child column over the parent column * @return table with inherited columns */ - public static PTable addDerivedColumnsFromParent(PhoenixConnection connection, + public static PTable addDerivedColumnsFromParent(PhoenixMonitoredConnection connection, PTable view, PTable parentTable, boolean recalculateBaseColumnCount) throws SQLException { @@ -1013,7 +1014,7 @@ public static void addTagsToPutsForViewAlteredProperties(List tableMet * @throws IOException * @throws SQLException */ - public static List getViewIndexIds(final PhoenixConnection connection, final String tableName, final boolean includeTenantViewIndexes) + public static List getViewIndexIds(final PhoenixMonitoredConnection connection, final String tableName, final boolean includeTenantViewIndexes) throws IOException, SQLException { Preconditions.checkArgument(MetaDataUtil.isViewIndex(tableName)); final List viewIndexIdsString = new ArrayList<>(); diff --git a/phoenix-core-client/src/main/java/org/apache/phoenix/util/csv/CsvUpsertExecutor.java b/phoenix-core-client/src/main/java/org/apache/phoenix/util/csv/CsvUpsertExecutor.java index 2d5033f0e64..8140d804cd5 100644 --- a/phoenix-core-client/src/main/java/org/apache/phoenix/util/csv/CsvUpsertExecutor.java +++ b/phoenix-core-client/src/main/java/org/apache/phoenix/util/csv/CsvUpsertExecutor.java @@ -32,6 +32,7 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.expression.function.EncodeFormat; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.query.QueryServicesOptions; import org.apache.phoenix.schema.IllegalDataException; @@ -130,7 +131,7 @@ static class SimpleDatatypeConversionFunction implements Function metadataCols = SchemaUtil.getColumnNames(pMetadata.getColumns()); return queryMetadata(conn, metadataCols, qSourceTableName, qTargetTableName, diff --git a/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/index/IndexVerificationOutputRepository.java b/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/index/IndexVerificationOutputRepository.java index 57a32dd96cd..62c577a1e38 100644 --- a/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/index/IndexVerificationOutputRepository.java +++ b/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/index/IndexVerificationOutputRepository.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.mapreduce.index; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.thirdparty.com.google.common.annotations.VisibleForTesting; import org.apache.hadoop.hbase.TableExistsException; @@ -115,7 +116,7 @@ public IndexVerificationOutputRepository() { @VisibleForTesting public IndexVerificationOutputRepository(byte[] indexName, Connection conn) throws SQLException { ConnectionQueryServices queryServices = - conn.unwrap(PhoenixConnection.class).getQueryServices(); + conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); outputTable = queryServices.getTable(OUTPUT_TABLE_NAME_BYTES); indexTable = queryServices.getTable(indexName); } @@ -177,7 +178,7 @@ private static byte[] generatePartialOutputTableRowKey(long ts, byte[] indexTabl } public void createOutputTable(Connection connection) throws IOException, SQLException { - ConnectionQueryServices queryServices = connection.unwrap(PhoenixConnection.class).getQueryServices(); + ConnectionQueryServices queryServices = connection.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); try (Admin admin = queryServices.getAdmin()) { TableName outputTableName = TableName.valueOf(OUTPUT_TABLE_NAME); if (!admin.tableExists(outputTableName)) { diff --git a/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/index/IndexVerificationResultRepository.java b/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/index/IndexVerificationResultRepository.java index c00b2ae9208..29dbb0bfead 100644 --- a/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/index/IndexVerificationResultRepository.java +++ b/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/index/IndexVerificationResultRepository.java @@ -39,6 +39,7 @@ import org.apache.phoenix.hbase.index.table.HTableFactory; import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.ConnectionQueryServices; import org.apache.phoenix.query.QueryConstants; import org.apache.phoenix.util.ByteUtil; @@ -163,7 +164,7 @@ public IndexVerificationResultRepository(byte[] indexName, } public void createResultTable(Connection connection) throws IOException, SQLException { - ConnectionQueryServices queryServices = connection.unwrap(PhoenixConnection.class).getQueryServices(); + ConnectionQueryServices queryServices = connection.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); try (Admin admin = queryServices.getAdmin()) { TableName resultTableName = TableName.valueOf(RESULT_TABLE_NAME); if (!admin.tableExists(resultTableName)) { diff --git a/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/util/DefaultPhoenixMultiViewListProvider.java b/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/util/DefaultPhoenixMultiViewListProvider.java index 480ae3b3f2b..f6fb63a6ee1 100644 --- a/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/util/DefaultPhoenixMultiViewListProvider.java +++ b/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/util/DefaultPhoenixMultiViewListProvider.java @@ -19,6 +19,7 @@ import org.apache.hadoop.conf.Configuration; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.QueryConstants; import org.apache.phoenix.schema.PTable; import org.apache.phoenix.schema.PTableType; @@ -57,7 +58,7 @@ public List getPhoenixMultiViewList(Configuration configuratio } String tenantId = configuration.get(PhoenixConfigurationUtil.MAPREDUCE_TENANT_ID); - try (PhoenixConnection connection = (PhoenixConnection) + try (PhoenixMonitoredConnection connection = (PhoenixMonitoredConnection) ConnectionUtil.getInputConnection(configuration)){ try (PreparedStatement stmt = connection.prepareStatement(query)) { do { @@ -103,7 +104,7 @@ public List getTenantOrViewMultiViewList(Configuration configu List viewInfoWritables = new ArrayList<>(); String query = PhoenixMultiInputUtil.getFetchViewQuery(configuration); - try (PhoenixConnection connection = (PhoenixConnection) + try (PhoenixMonitoredConnection connection = (PhoenixMonitoredConnection) ConnectionUtil.getInputConnection(configuration)) { try (Statement stmt = connection.createStatement()) { ResultSet viewRs = stmt.executeQuery(query); @@ -130,7 +131,7 @@ public List getTenantOrViewMultiViewList(Configuration configu return viewInfoWritables; } - private boolean isParentHasTTL(PhoenixConnection connection, + private boolean isParentHasTTL(PhoenixMonitoredConnection connection, String tenantId, String fullTableName) { boolean skip= false; try { @@ -160,7 +161,7 @@ private boolean isParentHasTTL(PhoenixConnection connection, return skip; } - private void addingViewIndexToTheFinalList(PhoenixConnection connection, String tenantId, + private void addingViewIndexToTheFinalList(PhoenixMonitoredConnection connection, String tenantId, String fullTableName, long viewTtlValue, List viewInfoWritables) throws Exception { diff --git a/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/util/PhoenixMultiInputUtil.java b/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/util/PhoenixMultiInputUtil.java index 8c28a8d2bbd..235f4a99092 100644 --- a/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/util/PhoenixMultiInputUtil.java +++ b/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/util/PhoenixMultiInputUtil.java @@ -48,7 +48,11 @@ public class PhoenixMultiInputUtil { public static Connection buildTenantConnection(String url, String tenantId) throws SQLException { - Properties props = new Properties(); + return buildTenantConnection(new Properties(), url, tenantId); + } + + public static Connection buildTenantConnection(Properties props, String url, String tenantId) + throws SQLException { props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); return DriverManager.getConnection(url, props); } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/coprocessor/StatisticsCollectionRunTrackerIT.java b/phoenix-core/src/it/java/org/apache/phoenix/coprocessor/StatisticsCollectionRunTrackerIT.java index cdc78c35852..84abacd7618 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/coprocessor/StatisticsCollectionRunTrackerIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/coprocessor/StatisticsCollectionRunTrackerIT.java @@ -19,6 +19,7 @@ import static org.apache.phoenix.schema.stats.StatisticsCollectionRunTracker.COMPACTION_UPDATE_STATS_ROW_COUNT; import static org.apache.phoenix.schema.stats.StatisticsCollectionRunTracker.CONCURRENT_UPDATE_STATS_ROW_COUNT; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -37,7 +38,9 @@ import org.apache.phoenix.end2end.ParallelStatsEnabledIT; import org.apache.phoenix.end2end.ParallelStatsEnabledTest; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.schema.stats.StatisticsCollectionRunTracker; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.util.TestUtil; import org.junit.Assert; @@ -86,7 +89,7 @@ public void testStateBeforeAndAfterMajorCompaction() throws Exception { // Upsert values in the table. String keyPrefix = "aaaaaaaaaaaaaaaaaaaa"; String upsert = "UPSERT INTO " + tableName + " VALUES (?, ?)"; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { PreparedStatement stmt = conn.prepareStatement(upsert); for (int i = 0; i < 1000; i++) { stmt.setString(1, keyPrefix + i); @@ -150,10 +153,10 @@ private void markRunningUpdateStats(RegionInfo regionInfo, HashSet famil private RegionInfo createTableAndGetRegion(String tableName) throws Exception { TableName tn = TableName.valueOf(tableName); String ddl = "CREATE TABLE " + tableName + " (PK1 VARCHAR PRIMARY KEY, KV1 VARCHAR)"; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute(ddl); conn.createStatement().execute("CREATE LOCAL INDEX " + generateUniqueName() + " ON " + tableName + "(KV1)"); - PhoenixConnection phxConn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection phxConn = conn.unwrap(PhoenixMonitoredConnection.class); try (Admin admin = phxConn.getQueryServices().getAdmin()) { List tableRegions = admin.getRegions(tn); return tableRegions.get(0); @@ -162,13 +165,13 @@ private RegionInfo createTableAndGetRegion(String tableName) throws Exception { } private long runUpdateStats(String tableName) throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { return conn.createStatement().executeUpdate("UPDATE STATISTICS " + tableName); } } private void runMajorCompaction(String tableName) throws Exception { - try (PhoenixConnection conn = DriverManager.getConnection(getUrl()).unwrap(PhoenixConnection.class)) { + try (PhoenixMonitoredConnection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixMonitoredConnection.class)) { try (Admin admin = conn.getQueryServices().getAdmin()) { TableName t = TableName.valueOf(tableName); admin.flush(t); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AbsFunctionEnd2EndIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AbsFunctionEnd2EndIT.java index 0728a4a1acc..7ad66eda373 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AbsFunctionEnd2EndIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AbsFunctionEnd2EndIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.apache.phoenix.util.TestUtil.closeStmtAndConn; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -28,6 +29,7 @@ import java.sql.ResultSet; import org.apache.phoenix.expression.function.AbsFunction; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -35,6 +37,7 @@ /** * End to end tests for {@link AbsFunction} */ + @Category(ParallelStatsDisabledTest.class) public class AbsFunctionEnd2EndIT extends ParallelStatsDisabledIT { @@ -46,7 +49,7 @@ public void initTable() throws Exception { Connection conn = null; PreparedStatement stmt = null; try { - conn = DriverManager.getConnection(getUrl()); + conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String ddl; ddl = "CREATE TABLE " + TABLE_NAME + " (k VARCHAR NOT NULL PRIMARY KEY, \"DEC\" DECIMAL, doub DOUBLE, fl FLOAT, inte INTEGER, lon BIGINT, smalli SMALLINT, tinyi TINYINT)"; conn.createStatement().execute(ddl); @@ -101,7 +104,7 @@ private void testSignedNumberSpec(Connection conn, double data) throws Exception @Test public void testSignedNumber() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); testSignedNumberSpec(conn, 0.0); testSignedNumberSpec(conn, 1.0); testSignedNumberSpec(conn, -1.0); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateIT.java index 5d1a64f402a..a1f5f76832f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateIT.java @@ -38,7 +38,6 @@ import org.apache.phoenix.util.TestUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class AggregateIT extends BaseAggregateIT { @@ -82,7 +81,7 @@ public void testGroupByWithAliasWithSameColumnName() throws SQLException { @Test public void testGroupByCoerceExpressionBug3453() throws Exception { - final Connection conn = DriverManager.getConnection(getUrl()); + final Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { //Type is INT String intTableName=generateUniqueName(); @@ -144,7 +143,7 @@ public void testGroupByCoerceExpressionBug3453() throws Exception { public void testNestedGroupedAggregationWithBigInt() throws Exception { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); String tableName = generateUniqueName(); - try(Connection conn = DriverManager.getConnection(getUrl(), props);) { + try(Connection conn = DriverManager.getConnection(getUrl(), props)) { String createQuery="CREATE TABLE "+tableName+" (a BIGINT NOT NULL,c BIGINT NOT NULL CONSTRAINT PK PRIMARY KEY (a, c))"; String updateQuery="UPSERT INTO "+tableName+"(a,c) VALUES(4444444444444444444, 5555555555555555555)"; String query="SELECT a FROM (SELECT a, c FROM "+tableName+" GROUP BY a, c) GROUP BY a, c"; @@ -195,7 +194,7 @@ public void testAvgGroupByOrderPreservingWithStats() throws Exception { @Override protected void testCountNullInNonEmptyKeyValueCF(int columnEncodedBytes) throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { //Type is INT String intTableName=generateUniqueName(); String sql="create table " + intTableName + " (mykey integer not null primary key, A.COLA integer, B.COLB integer) " diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateQueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateQueryIT.java index 6cf51d11949..8719790f5c9 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateQueryIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateQueryIT.java @@ -41,13 +41,12 @@ import org.apache.hadoop.hbase.client.ConnectionFactory; import org.apache.hadoop.hbase.client.RegionLocator; import org.apache.hadoop.hbase.util.Bytes; -import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.util.ByteUtil; import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.runners.Parameterized.Parameters; - @Category(ParallelStatsDisabledTest.class) public class AggregateQueryIT extends BaseQueryIT { @@ -104,8 +103,8 @@ public void testSplitWithCachedMeta() throws Exception { assertFalse(rs.next()); TableName tn =TableName.valueOf(tableName); - admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin(); - Configuration configuration = conn.unwrap(PhoenixConnection.class).getQueryServices().getConfiguration(); + admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin(); + Configuration configuration = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getConfiguration(); org.apache.hadoop.hbase.client.Connection hbaseConn = ConnectionFactory.createConnection(configuration); RegionLocator regionLocator = hbaseConn.getRegionLocator(TableName.valueOf(tableName)); regionLocator.clearRegionLocationCache(); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateQueryWithRegionMoves2IT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateQueryWithRegionMoves2IT.java index 20066ab3224..f6de2cc4a3f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateQueryWithRegionMoves2IT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateQueryWithRegionMoves2IT.java @@ -38,6 +38,8 @@ import java.util.HashMap; import java.util.Map; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; + @Category(NeedsOwnMiniClusterTest.class) public class AggregateQueryWithRegionMoves2IT extends AggregateQueryWithRegionMovesIT { @@ -125,7 +127,11 @@ public static synchronized void doSetup() throws Exception { TestScanningResultPostDummyResultCaller.class.getName()); props.put(QueryServices.PHOENIX_POST_VALID_PROCESS, TestScanningResultPostValidResultCaller.class.getName()); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @AfterClass diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateQueryWithRegionMovesIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateQueryWithRegionMovesIT.java index ee1aae8f87b..85d2bbafbfb 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateQueryWithRegionMovesIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateQueryWithRegionMovesIT.java @@ -24,6 +24,7 @@ import org.apache.hadoop.hbase.client.RegionLocator; import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.util.ByteUtil; import org.apache.phoenix.util.PropertiesUtil; import org.junit.After; @@ -50,7 +51,6 @@ import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; - @Category(NeedsOwnMiniClusterTest.class) public class AggregateQueryWithRegionMovesIT extends BaseQueryWithRegionMovesIT { @@ -129,9 +129,9 @@ public void testSplitWithCachedMeta() throws Exception { assertFalse(rs.next()); TableName tn = TableName.valueOf(tableName); - admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin(); + admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin(); Configuration configuration = - conn.unwrap(PhoenixConnection.class).getQueryServices().getConfiguration(); + conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getConfiguration(); org.apache.hadoop.hbase.client.Connection hbaseConn = ConnectionFactory.createConnection(configuration); RegionLocator regionLocator = hbaseConn.getRegionLocator(TableName.valueOf(tableName)); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateWithRegionMoves2IT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateWithRegionMoves2IT.java index 6bd47b8f00a..4e149d34835 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateWithRegionMoves2IT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateWithRegionMoves2IT.java @@ -36,6 +36,8 @@ import java.util.HashMap; import java.util.Map; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; + @Category(NeedsOwnMiniClusterTest.class) public class AggregateWithRegionMoves2IT extends AggregateWithRegionMovesIT { @@ -113,8 +115,11 @@ public static synchronized void doSetup() throws Exception { TestScanningResultPostDummyResultCaller.class.getName()); props.put(QueryServices.PHOENIX_POST_VALID_PROCESS, TestScanningResultPostValidResultCaller.class.getName()); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); - } + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @AfterClass public static synchronized void freeResources() throws Exception { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateWithRegionMovesIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateWithRegionMovesIT.java index e07bcb0d110..b8b1c757618 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateWithRegionMovesIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateWithRegionMovesIT.java @@ -39,7 +39,6 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; - @Category(NeedsOwnMiniClusterTest.class) public class AggregateWithRegionMovesIT extends BaseAggregateWithRegionMovesIT { @@ -117,7 +116,7 @@ public void testGroupByWithAliasWithSameColumnName() throws Exception { @Test public void testGroupByCoerceExpressionBug3453() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { //Type is INT String intTableName = generateUniqueName(); String sql = "CREATE TABLE " + intTableName + "(" + @@ -285,7 +284,7 @@ public void testAvgGroupByDescOrderPreservingWithStats() throws Exception { @Override protected void testCountNullInNonEmptyKeyValueCF(int columnEncodedBytes) throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { //Type is INT String intTableName = generateUniqueName(); TABLE_NAMES.add(intTableName); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterAddCascadeIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterAddCascadeIndexIT.java index 84aa678ee85..517ba6f087c 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterAddCascadeIndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterAddCascadeIndexIT.java @@ -33,6 +33,7 @@ import org.apache.phoenix.schema.types.PLong; import org.apache.phoenix.schema.types.PVarchar; import org.apache.phoenix.util.ColumnInfo; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.SchemaUtil; import org.junit.Before; import org.junit.Rule; @@ -54,10 +55,10 @@ import java.util.Collection; import java.util.Properties; +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; - @Category(ParallelStatsDisabledTest.class) @RunWith(Parameterized.class) public class AlterAddCascadeIndexIT extends ParallelStatsDisabledIT { @@ -97,7 +98,7 @@ public static Collection data() { @Before public void setup() throws SQLException { - prop = new Properties(); + prop = PropertiesUtil.deepCopy(TEST_PROPERTIES); conn = DriverManager.getConnection(getUrl(), prop); conn.setAutoCommit(true); String schemaName = "S_"+generateUniqueName(); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterMultiTenantTableWithViewsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterMultiTenantTableWithViewsIT.java index d16619e6c59..5f34f4cddb5 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterMultiTenantTableWithViewsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterMultiTenantTableWithViewsIT.java @@ -19,6 +19,7 @@ import static org.apache.phoenix.query.QueryConstants.BASE_TABLE_BASE_COLUMN_COUNT; import static org.apache.phoenix.query.QueryConstants.DIVERGED_VIEW_BASE_COLUMN_COUNT; +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.assertNotNull; @@ -42,6 +43,7 @@ import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixStatement; import org.apache.phoenix.schema.ColumnNotFoundException; import org.apache.phoenix.schema.PColumn; @@ -51,27 +53,27 @@ import org.apache.phoenix.schema.PTableType; import org.apache.phoenix.util.IndexUtil; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.util.ViewUtil; import org.junit.Test; import org.junit.experimental.categories.Category; import org.apache.phoenix.thirdparty.com.google.common.base.Objects; - @Category(NeedsOwnMiniClusterTest.class) public class AlterMultiTenantTableWithViewsIT extends SplitSystemCatalogIT { private Connection getTenantConnection(String tenantId) throws Exception { - Properties tenantProps = new Properties(); + Properties tenantProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); return DriverManager.getConnection(getUrl(), tenantProps); } - private static long getTableSequenceNumber(PhoenixConnection conn, String tableName) throws SQLException { + private static long getTableSequenceNumber(PhoenixMonitoredConnection conn, String tableName) throws SQLException { PTable table = conn.getTable(new PTableKey(conn.getTenantId(), SchemaUtil.normalizeIdentifier(tableName))); return table.getSequenceNumber(); } - private static short getMaxKeySequenceNumber(PhoenixConnection conn, String tableName) throws SQLException { + private static short getMaxKeySequenceNumber(PhoenixMonitoredConnection conn, String tableName) throws SQLException { PTable table = conn.getTable(new PTableKey(conn.getTenantId(), SchemaUtil.normalizeIdentifier(tableName))); return SchemaUtil.getMaxKeySeq(table); } @@ -99,7 +101,7 @@ public void testCreateAndAlterViewsWithChangeDetectionEnabled() throws Exception PTable globalView = null; PTable alteredGlobalView = null; - try (PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl())) { + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String ddl = "CREATE TABLE " + fullTableName + " (id char(1) NOT NULL," + " col1 integer NOT NULL," + " col2 bigint NOT NULL," + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1, col2)) " + @@ -131,9 +133,9 @@ public void testCreateAndAlterViewsWithChangeDetectionEnabled() throws Exception AlterTableIT.verifySchemaExport(alteredGlobalView, getUtility().getConfiguration()); } - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); - try (PhoenixConnection tenantConn = (PhoenixConnection) DriverManager.getConnection(getUrl(), props)) { + try (PhoenixMonitoredConnection tenantConn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), props)) { String tenantViewDdl = "CREATE VIEW " + fullTenantViewName + " (col5 VARCHAR NULL) " + " AS SELECT * FROM " + fullGlobalViewName + " CHANGE_DETECTION_ENABLED=true"; @@ -161,7 +163,7 @@ public void testAddDropColumnToBaseTablePropagatesToEntireViewHierarchy() throws / view2(tenant1) */ - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String baseTableDDL = "CREATE TABLE " + baseTable + " (TENANT_ID VARCHAR NOT NULL, PK1 VARCHAR NOT NULL, V1 VARCHAR, V2 VARCHAR CONSTRAINT NAME_PK PRIMARY KEY(TENANT_ID, PK1)) MULTI_TENANT = true "; conn.createStatement().execute(baseTableDDL); @@ -250,7 +252,7 @@ public void testChangingPKOfBaseTableChangesPKForAllViews() throws Exception { view2(tenant1) */ Connection tenant1Conn = null, tenant2Conn = null; - try (Connection globalConn = DriverManager.getConnection(getUrl())) { + try (Connection globalConn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String baseTableDDL = "CREATE TABLE " + baseTable + " (TENANT_ID VARCHAR NOT NULL, PK1 VARCHAR NOT NULL, V1 VARCHAR, V2 VARCHAR CONSTRAINT NAME_PK PRIMARY KEY(TENANT_ID, PK1)) MULTI_TENANT = true "; @@ -276,19 +278,19 @@ public void testChangingPKOfBaseTableChangesPKForAllViews() throws Exception { // verify that the new column new_pk is now part of the primary key for the entire hierarchy globalConn.createStatement().execute("SELECT * FROM " + baseTable); - assertTrue(checkColumnPartOfPk(globalConn.unwrap(PhoenixConnection.class), "NEW_PK", baseTable)); + assertTrue(checkColumnPartOfPk(globalConn.unwrap(PhoenixMonitoredConnection.class), "NEW_PK", baseTable)); tenant1Conn.createStatement().execute("SELECT * FROM " + view1); - assertTrue(checkColumnPartOfPk(tenant1Conn.unwrap(PhoenixConnection.class), "NEW_PK", view1)); + assertTrue(checkColumnPartOfPk(tenant1Conn.unwrap(PhoenixMonitoredConnection.class), "NEW_PK", view1)); tenant1Conn.createStatement().execute("SELECT * FROM " + view2); - assertTrue(checkColumnPartOfPk(tenant1Conn.unwrap(PhoenixConnection.class), "NEW_PK", view2)); + assertTrue(checkColumnPartOfPk(tenant1Conn.unwrap(PhoenixMonitoredConnection.class), "NEW_PK", view2)); tenant2Conn.createStatement().execute("SELECT * FROM " + view3); - assertTrue(checkColumnPartOfPk(tenant2Conn.unwrap(PhoenixConnection.class), "NEW_PK", view3)); + assertTrue(checkColumnPartOfPk(tenant2Conn.unwrap(PhoenixMonitoredConnection.class), "NEW_PK", view3)); globalConn.createStatement().execute("SELECT * FROM " + view4); - assertTrue(checkColumnPartOfPk(globalConn.unwrap(PhoenixConnection.class), "NEW_PK", view4)); + assertTrue(checkColumnPartOfPk(globalConn.unwrap(PhoenixMonitoredConnection.class), "NEW_PK", view4)); } finally { if (tenant1Conn != null) { @@ -305,7 +307,7 @@ public void testChangingPKOfBaseTableChangesPKForAllViews() throws Exception { } - private boolean checkColumnPartOfPk(PhoenixConnection conn, String columnName, String tableName) throws SQLException { + private boolean checkColumnPartOfPk(PhoenixMonitoredConnection conn, String columnName, String tableName) throws SQLException { String normalizedTableName = SchemaUtil.normalizeIdentifier(tableName); PTable table = conn.getTable(new PTableKey(conn.getTenantId(), normalizedTableName)); List pkCols = table.getPKColumns(); @@ -318,7 +320,7 @@ private boolean checkColumnPartOfPk(PhoenixConnection conn, String columnName, S return false; } - private int getIndexOfPkColumn(PhoenixConnection conn, String columnName, String tableName) throws SQLException { + private int getIndexOfPkColumn(PhoenixMonitoredConnection conn, String columnName, String tableName) throws SQLException { String normalizedTableName = SchemaUtil.normalizeIdentifier(tableName); PTable table = conn.getTable(new PTableKey(conn.getTenantId(), normalizedTableName)); List pkCols = table.getPKColumns(); @@ -351,7 +353,7 @@ public void testAddPKColumnToBaseTableWhoseViewsHaveIndices() throws Exception { / view2(tenant1, index) */ - try (Connection globalConn = DriverManager.getConnection(getUrl())) { + try (Connection globalConn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { // make sure that the tables are empty, but reachable globalConn .createStatement() @@ -365,7 +367,7 @@ public void testAddPKColumnToBaseTableWhoseViewsHaveIndices() throws Exception { try (Connection viewConn = getTenantConnection(tenant1)) { // create tenant specific view for tenant1 - view1 viewConn.createStatement().execute("CREATE VIEW " + view1 + " AS SELECT * FROM " + baseTable); - PhoenixConnection phxConn = viewConn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection phxConn = viewConn.unwrap(PhoenixMonitoredConnection.class); assertEquals(0, getTableSequenceNumber(phxConn, view1)); assertEquals(2, getMaxKeySequenceNumber(phxConn, view1)); @@ -384,7 +386,7 @@ public void testAddPKColumnToBaseTableWhoseViewsHaveIndices() throws Exception { try (Connection viewConn = getTenantConnection(tenant2)) { // create tenant specific view for tenant2 - view3 viewConn.createStatement().execute("CREATE VIEW " + view3 + " AS SELECT * FROM " + baseTable); - PhoenixConnection phxConn = viewConn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection phxConn = viewConn.unwrap(PhoenixMonitoredConnection.class); assertEquals(0, getTableSequenceNumber(phxConn, view3)); assertEquals(2, getMaxKeySequenceNumber(phxConn, view3)); @@ -396,9 +398,9 @@ public void testAddPKColumnToBaseTableWhoseViewsHaveIndices() throws Exception { } // alter the base table by adding 1 non-pk and 2 pk columns - try (Connection globalConn = DriverManager.getConnection(getUrl())) { + try (Connection globalConn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { globalConn.createStatement().execute("ALTER TABLE " + baseTable + " ADD v3 VARCHAR, k2 VARCHAR PRIMARY KEY, k3 VARCHAR PRIMARY KEY"); - assertEquals(4, getMaxKeySequenceNumber(globalConn.unwrap(PhoenixConnection.class), baseTable)); + assertEquals(4, getMaxKeySequenceNumber(globalConn.unwrap(PhoenixMonitoredConnection.class), baseTable)); // Upsert records in the base table String upsert = "UPSERT INTO " + baseTable + " (TENANT_ID, K1, K2, K3, V1, V2, V3) VALUES (?, ?, ?, ?, ?, ?, ?)"; @@ -427,7 +429,7 @@ public void testAddPKColumnToBaseTableWhoseViewsHaveIndices() throws Exception { try (Connection viewConn = getTenantConnection(tenant1)) { ResultSet rs = viewConn.createStatement().executeQuery("SELECT K2, K3, V3 FROM " + view1); - PhoenixConnection phxConn = viewConn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection phxConn = viewConn.unwrap(PhoenixMonitoredConnection.class); assertEquals(2, getIndexOfPkColumn(phxConn, "k2", view1)); assertEquals(3, getIndexOfPkColumn(phxConn, "k3", view1)); assertEquals(0, getTableSequenceNumber(phxConn, view1)); @@ -449,7 +451,7 @@ public void testAddPKColumnToBaseTableWhoseViewsHaveIndices() throws Exception { } try (Connection viewConn = getTenantConnection(tenant2)) { ResultSet rs = viewConn.createStatement().executeQuery("SELECT K2, K3, V3 FROM " + view3); - PhoenixConnection phxConn = viewConn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection phxConn = viewConn.unwrap(PhoenixMonitoredConnection.class); assertEquals(2, getIndexOfPkColumn(phxConn, "k2", view3)); assertEquals(3, getIndexOfPkColumn(phxConn, "k3", view3)); assertEquals(0, getTableSequenceNumber(phxConn, view3)); @@ -490,7 +492,7 @@ public void testAddingPkAndKeyValueColumnsToBaseTableWithDivergedView() throws E view1(tenant1) divergedView(tenant2) */ - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenant1Conn = getTenantConnection(tenant1); Connection tenant2Conn = getTenantConnection(tenant2)) { String baseTableDDL = "CREATE TABLE " + baseTable + " (TENANT_ID VARCHAR NOT NULL, PK1 VARCHAR NOT NULL, V1 VARCHAR, V2 VARCHAR, V3 VARCHAR CONSTRAINT NAME_PK PRIMARY KEY(TENANT_ID, PK1)) MULTI_TENANT = true "; @@ -560,7 +562,7 @@ public void testAddColumnsToSaltedBaseTableWithViews() throws Exception { String baseTable = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String view1 = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); String tenant = TENANT1; - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenant1Conn = getTenantConnection(tenant)) { String baseTableDDL = "CREATE TABLE " + baseTable @@ -592,7 +594,7 @@ public void testDropColumnsFromSaltedBaseTableWithViews() throws Exception { String baseTable = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String view1 = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); String tenant = TENANT1; - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenant1Conn = getTenantConnection(tenant)) { String baseTableDDL = "CREATE TABLE " + baseTable @@ -634,17 +636,17 @@ public void testAlteringViewConditionallyModifiesHTableMetadata() throws Excepti String baseTable = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String view1 = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); String tenant = TENANT1; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES));) { String baseTableDDL = "CREATE TABLE " + baseTable + " (TENANT_ID VARCHAR NOT NULL, PK1 VARCHAR NOT NULL, V1 VARCHAR, V2 VARCHAR, V3 VARCHAR CONSTRAINT NAME_PK PRIMARY KEY(TENANT_ID, PK1)) MULTI_TENANT = true "; conn.createStatement().execute(baseTableDDL); - TableDescriptor tableDesc1 = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin().getDescriptor(TableName.valueOf(baseTable)); + TableDescriptor tableDesc1 = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin().getDescriptor(TableName.valueOf(baseTable)); try (Connection tenant1Conn = getTenantConnection(tenant)) { String view1DDL = "CREATE VIEW " + view1 + " ( VIEW_COL1 DECIMAL(10,2), VIEW_COL2 CHAR(256)) AS SELECT * FROM " + baseTable; tenant1Conn.createStatement().execute(view1DDL); // This should not modify the base table String alterView = "ALTER VIEW " + view1 + " ADD NEWCOL1 VARCHAR"; tenant1Conn.createStatement().execute(alterView); - TableDescriptor tableDesc2 = tenant1Conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin().getDescriptor(TableName.valueOf(baseTable)); + TableDescriptor tableDesc2 = tenant1Conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin().getDescriptor(TableName.valueOf(baseTable)); assertEquals(tableDesc1, tableDesc2); // Add a new column family that doesn't already exist in the base table @@ -652,14 +654,14 @@ public void testAlteringViewConditionallyModifiesHTableMetadata() throws Excepti tenant1Conn.createStatement().execute(alterView); // Verify that the column family now shows up in the base table descriptor - tableDesc2 = tenant1Conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin().getDescriptor(TableName.valueOf(baseTable)); + tableDesc2 = tenant1Conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin().getDescriptor(TableName.valueOf(baseTable)); assertFalse(tableDesc2.equals(tableDesc1)); assertNotNull(tableDesc2.getColumnFamily(Bytes.toBytes("CF"))); // Add a column with an existing column family. This shouldn't modify the base table. alterView = "ALTER VIEW " + view1 + " ADD CF.NEWCOL3 VARCHAR"; tenant1Conn.createStatement().execute(alterView); - TableDescriptor tableDesc3 = tenant1Conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin().getDescriptor(TableName.valueOf(baseTable)); + TableDescriptor tableDesc3 = tenant1Conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin().getDescriptor(TableName.valueOf(baseTable)); assertTrue(tableDesc3.equals(tableDesc2)); assertNotNull(tableDesc3.getColumnFamily(Bytes.toBytes("CF"))); } @@ -671,10 +673,10 @@ public void testCacheInvalidatedAfterAddingColumnToBaseTableWithViews() throws E String baseTable = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String viewName = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); String tenantId = TENANT1; - try (Connection globalConn = DriverManager.getConnection(getUrl())) { + try (Connection globalConn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES));) { String tableDDL = "CREATE TABLE " + baseTable + " (TENANT_ID VARCHAR NOT NULL, PK1 VARCHAR NOT NULL, V1 VARCHAR CONSTRAINT NAME_PK PRIMARY KEY(TENANT_ID, PK1)) MULTI_TENANT = true" ; globalConn.createStatement().execute(tableDDL); - Properties tenantProps = new Properties(); + Properties tenantProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); // create a tenant specific view try (Connection tenantConn = DriverManager.getConnection(getUrl(), tenantProps)) { @@ -696,13 +698,13 @@ public void testCacheInvalidatedAfterDroppingColumnFromBaseTableWithViews() thro String baseTable = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String viewName = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); String tenantId = TENANT1; - try (Connection globalConn = DriverManager.getConnection(getUrl())) { + try (Connection globalConn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES));) { String tableDDL = "CREATE TABLE " + baseTable + " (TENANT_ID VARCHAR NOT NULL, PK1 VARCHAR NOT NULL, V1 VARCHAR CONSTRAINT NAME_PK PRIMARY KEY(TENANT_ID, PK1)) MULTI_TENANT = true" ; globalConn.createStatement().execute(tableDDL); - Properties tenantProps = new Properties(); + Properties tenantProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); // create a tenant specific view try (Connection tenantConn = DriverManager.getConnection(getUrl(), tenantProps)) { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterSessionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterSessionIT.java index a39db134386..7ac768a82a1 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterSessionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterSessionIT.java @@ -28,7 +28,7 @@ import java.util.Properties; import org.apache.hadoop.hbase.client.Consistency; -import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.util.PhoenixRuntime; import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.QueryUtil; @@ -63,7 +63,7 @@ public void testUpdateConsistency() throws Exception { Statement st = conn.createStatement(); st.execute("alter session set Consistency = 'timeline'"); ResultSet rs = st.executeQuery("explain select * from " + tableName); - assertEquals(Consistency.TIMELINE, conn.unwrap(PhoenixConnection.class).getConsistency()); + assertEquals(Consistency.TIMELINE, conn.unwrap(PhoenixMonitoredConnection.class).getConsistency()); String queryPlan = QueryUtil.getExplainPlan(rs); assertTrue(queryPlan.indexOf("TIMELINE") > 0); @@ -80,7 +80,7 @@ public void testSetConsistencyInURL() throws Exception { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); try (Connection conn = DriverManager.getConnection(getUrl() + PhoenixRuntime.JDBC_PROTOCOL_TERMINATOR + "Consistency=TIMELINE", props)) { - assertEquals(Consistency.TIMELINE, ((PhoenixConnection)conn).getConsistency()); + assertEquals(Consistency.TIMELINE, ((PhoenixMonitoredConnection)conn).getConsistency()); Statement st = conn.createStatement(); ResultSet rs = st.executeQuery("explain select * from " + tableName); String queryPlan = QueryUtil.getExplainPlan(rs); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java index 5648d0409c9..e0606eff065 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java @@ -58,8 +58,8 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.coprocessor.MetaDataEndpointImpl; import org.apache.phoenix.exception.SQLExceptionCode; -import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.BaseTest; import org.apache.phoenix.query.ConnectionQueryServices; import org.apache.phoenix.query.QueryConstants; @@ -246,7 +246,7 @@ public void testAlterTableUpdatesSchemaRegistry() throws Exception { String schemaName = generateUniqueName(); String tableName = generateUniqueName(); String fullTableName = SchemaUtil.getTableName(schemaName, tableName); - try (PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl())) { + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String createDdl = "CREATE TABLE " + fullTableName + " (id char(1) NOT NULL," + " col1 integer NOT NULL," + " col2 bigint NOT NULL," + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1, col2)) " + @@ -277,7 +277,7 @@ public void testAlterChangeDetectionActivatesSchemaRegistryExport() throws Excep String schemaName = generateUniqueName(); String tableName = generateUniqueName(); String fullTableName = SchemaUtil.getTableName(schemaName, tableName); - try (PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl())) { + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String createDdl = "CREATE TABLE " + fullTableName + " (id char(1) NOT NULL," + " col1 integer NOT NULL," + " col2 bigint NOT NULL," + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1, col2)) " + " SCHEMA_VERSION='OLD'"; @@ -297,7 +297,7 @@ public void testChangeDetectionFalseDoesntExportToSchemaRegistry() throws Except String schemaName = generateUniqueName(); String tableName = generateUniqueName(); String fullTableName = SchemaUtil.getTableName(schemaName, tableName); - try (PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl())) { + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String createDdl = "CREATE TABLE " + fullTableName + " (id char(1) NOT NULL," + " col1 integer NOT NULL," + " col2 bigint NOT NULL," + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1, col2)) " + "CHANGE_DETECTION_ENABLED=false, SCHEMA_VERSION='OLD'"; @@ -345,7 +345,7 @@ public void testSetPropertyAndAddColumnForNewColumnFamily() throws Exception { try { conn.createStatement().execute(ddl); conn.createStatement().execute("ALTER TABLE " + dataTableFullName + " ADD CF.col2 integer CF.IN_MEMORY=true"); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { ColumnFamilyDescriptor[] columnFamilies = admin.getDescriptor(TableName.valueOf(dataTableFullName)).getColumnFamilies(); assertEquals(2, columnFamilies.length); assertEquals("0", columnFamilies[0].getNameAsString()); @@ -407,11 +407,11 @@ public void testSetSaltedTableAsImmutable() throws Exception { @Test public void testSetPropertySchemaVersion() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); final String schemaName = generateUniqueName(); final String tableName = generateUniqueName(); final String dataTableFullName = SchemaUtil.getTableName(schemaName, tableName); - try (PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl(), + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), props)) { CreateTableIT.testCreateTableSchemaVersionAndTopicNameHelper(conn, schemaName, tableName, "V1.0", null); final String version = "V1.1"; @@ -620,7 +620,7 @@ public void testDisallowAddingNotNullableColumnNotPartOfPkForExistingTable() thr } private void asssertIsWALDisabled(Connection conn, String fullTableName, boolean expectedValue) throws SQLException { - PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pconn = conn.unwrap(PhoenixMonitoredConnection.class); assertEquals(expectedValue, pconn.getTable(new PTableKey(pconn.getTenantId(), fullTableName)).isWALDisabled()); } @@ -1007,10 +1007,11 @@ public void testDropMultipleColumns() throws Exception { @Test public void testAlterTableOnGlobalIndex() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); - Statement stmt = conn.createStatement()) { + try (Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES))) + { + Statement stmt = conn.createStatement(); conn.setAutoCommit(false); - Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin(); + Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin(); String tableName = generateUniqueName(); String globalIndexTableName = generateUniqueName(); @@ -1067,7 +1068,7 @@ public void testAlterStoreNulls() throws SQLException { @Test public void testAddingPkColAndSettingProperties() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { String ddl = "create table " + dataTableFullName + " (" + " k1 char(1) NOT NULL," @@ -1122,7 +1123,7 @@ public void testAddingPkColAndSettingProperties() throws Exception { assertEquals(3, rs.getShort("KEY_SEQ")); assertFalse(rs.next()); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { TableDescriptor tableDesc = admin.getDescriptor(TableName.valueOf(dataTableFullName)); ColumnFamilyDescriptor[] columnFamilies = tableDesc.getColumnFamilies(); assertEquals(2, columnFamilies.length); @@ -1141,7 +1142,7 @@ public void testAddingPkColAndSettingProperties() throws Exception { @Test public void testClientCacheUpdatedOnChangingPhoenixTableProperties() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { String ddl = "create table " + dataTableFullName + " (" + " id char(1) NOT NULL," @@ -1165,7 +1166,7 @@ public void testClientCacheUpdatedOnChangingPhoenixTableProperties() throws Exce ddl = "ALTER TABLE " + dataTableFullName + " SET MULTI_TENANT = true"; conn.createStatement().execute(ddl); // check metadata cache is updated with MULTI_TENANT = true - PTable t = conn.unwrap(PhoenixConnection.class).getTable(new PTableKey(null, dataTableFullName)); + PTable t = conn.unwrap(PhoenixMonitoredConnection.class).getTable(new PTableKey(null, dataTableFullName)); assertTrue(t.isMultiTenant()); // check table metadata updated server side @@ -1184,11 +1185,11 @@ public void testClientCacheUpdatedOnChangingPhoenixTableProperties() throws Exce @Test public void testIndexColumnAsRowTimestamp() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute("CREATE TABLE " + dataTableFullName + " (PK1 DATE NOT NULL, PK2 VARCHAR NOT NULL, KV1 VARCHAR " + "CONSTRAINT PK PRIMARY KEY(PK1 ROW_TIMESTAMP, PK2)) " + tableDDLOptions); - PhoenixConnection phxConn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection phxConn = conn.unwrap(PhoenixMonitoredConnection.class); PTable table = phxConn.getTable(new PTableKey(phxConn.getTenantId(), dataTableFullName)); // Assert that the column shows up as row time stamp in the cache. @@ -1221,11 +1222,11 @@ public void testIndexColumnAsRowTimestamp() throws Exception { @Test public void testDeclaringColumnAsRowTimestamp() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute("CREATE TABLE " + dataTableFullName + " (PK1 DATE NOT NULL, PK2 VARCHAR NOT NULL, KV1 VARCHAR " + "CONSTRAINT PK PRIMARY KEY(PK1 ROW_TIMESTAMP, PK2)) " + tableDDLOptions); - PhoenixConnection phxConn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection phxConn = conn.unwrap(PhoenixMonitoredConnection.class); PTable table = phxConn.getTable(new PTableKey(phxConn.getTenantId(), dataTableFullName)); // Assert that the column shows up as row time stamp in the cache. @@ -1274,7 +1275,7 @@ private void assertIsRowTimestampSet(String schemaName, String tableName, String String sql = "SELECT IS_ROW_TIMESTAMP FROM \"SYSTEM\".\"CATALOG\" WHERE " + "(TABLE_SCHEM, TABLE_NAME) = ('" + schemaName + "','"+ tableName + "') AND\n" + "COLUMN_FAMILY IS NULL AND COLUMN_NAME = ?"; - try(Connection conn = DriverManager.getConnection(getUrl())) { + try(Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { PreparedStatement stmt = conn.prepareStatement(sql); stmt.setString(1, columnName); ResultSet rs = stmt.executeQuery(); @@ -1285,7 +1286,7 @@ private void assertIsRowTimestampSet(String schemaName, String tableName, String @Test public void testAddingRowTimestampColumnNotAllowedViaAlterTable() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute("CREATE TABLE " + dataTableFullName + " (PK1 VARCHAR NOT NULL, PK2 VARCHAR NOT NULL, KV1 VARCHAR CONSTRAINT PK PRIMARY KEY(PK1, PK2)) " + tableDDLOptions); // adding a new pk column that is also row_timestamp is not allowed try { @@ -1327,8 +1328,8 @@ public void testMetadataForImmutableTable() throws Exception { String viewName = generateUniqueName(); String fullTableName = schemaName + "." + baseTableName; String fullViewName = schemaName + "." + viewName; - try (Connection conn = DriverManager.getConnection(getUrl())) { - PhoenixConnection phxConn = conn.unwrap(PhoenixConnection.class); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { + PhoenixMonitoredConnection phxConn = conn.unwrap(PhoenixMonitoredConnection.class); conn.createStatement().execute("CREATE TABLE IF NOT EXISTS " + fullTableName + " (" + " ID char(1) NOT NULL," + " COL1 integer NOT NULL," @@ -1377,8 +1378,8 @@ public void testMetadataForMutableTable() throws Exception { String viewName = generateUniqueName(); String fullTableName = schemaName + "." + baseTableName; String fullViewName = schemaName + "." + viewName; - try (Connection conn = DriverManager.getConnection(getUrl())) { - PhoenixConnection phxConn = conn.unwrap(PhoenixConnection.class); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { + PhoenixMonitoredConnection phxConn = conn.unwrap(PhoenixMonitoredConnection.class); conn.createStatement().execute("CREATE TABLE IF NOT EXISTS " + fullTableName + " (" + " ID char(1) NOT NULL," + " COL1 integer NOT NULL," @@ -1425,11 +1426,11 @@ public void testAddingColumnsToTablesAndViews() throws Exception { String viewName = generateUniqueName(); String fullTableName = schemaName + "." + baseTableName; String fullViewName = schemaName + "." + viewName; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.put(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.toString(true)); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { conn.createStatement().execute("CREATE SCHEMA " + schemaName); - PhoenixConnection phxConn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection phxConn = conn.unwrap(PhoenixMonitoredConnection.class); conn.createStatement().execute("CREATE TABLE " + fullTableName + " (" + " ID char(1) NOT NULL," + " COL1 integer NOT NULL," @@ -1532,7 +1533,7 @@ public void testAddThenDropColumnTableDDLTimestamp() throws Exception { String columnAddDDL = "ALTER TABLE " + dataTableFullName + " ADD COL3 varchar(50) NULL "; String columnDropDDL = "ALTER TABLE " + dataTableFullName + " DROP COLUMN COL3 "; long startTS = EnvironmentEdgeManager.currentTimeMillis(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute(tableDDL); //first get the original DDL timestamp when we created the table long tableDDLTimestamp = CreateTableIT.verifyLastDDLTimestamp( @@ -1555,7 +1556,7 @@ public void testAddThenDropColumnTableDDLTimestamp() throws Exception { private void assertEncodedCQValue(String columnFamily, String columnName, String schemaName, String tableName, int expectedValue) throws Exception { String query = "SELECT " + COLUMN_QUALIFIER + " FROM \"SYSTEM\".CATALOG WHERE " + TABLE_SCHEM + " = ? AND " + TABLE_NAME + " = ? " + " AND " + COLUMN_FAMILY + " = ?" + " AND " + COLUMN_NAME + " = ?" + " AND " + COLUMN_QUALIFIER + " IS NOT NULL"; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { PreparedStatement stmt = conn.prepareStatement(query); stmt.setString(1, schemaName); stmt.setString(2, tableName); @@ -1575,7 +1576,7 @@ private void assertEncodedCQValue(String columnFamily, String columnName, String private void assertEncodedCQCounter(String columnFamily, String schemaName, String tableName, int expectedValue) throws Exception { String query = "SELECT " + COLUMN_QUALIFIER_COUNTER + " FROM \"SYSTEM\".CATALOG WHERE " + TABLE_SCHEM + " = ? AND " + TABLE_NAME + " = ? " + " AND " + COLUMN_FAMILY + " = ? AND " + COLUMN_QUALIFIER_COUNTER + " IS NOT NULL"; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { PreparedStatement stmt = conn.prepareStatement(query); stmt.setString(1, schemaName); stmt.setString(2, tableName); @@ -1595,7 +1596,7 @@ private void assertSequenceNumber(String schemaName, String tableName, long expe String query = "SELECT " + TABLE_SEQ_NUM + " FROM \"SYSTEM\".CATALOG WHERE " + TABLE_SCHEM + " = ? AND " + TABLE_NAME + " = ? AND " + TABLE_SEQ_NUM + " IS NOT NULL AND " + COLUMN_NAME + " IS NULL AND " + COLUMN_FAMILY + " IS NULL "; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { PreparedStatement stmt = conn.prepareStatement(query); stmt.setString(1, schemaName); stmt.setString(2, tableName); @@ -1666,9 +1667,9 @@ public void testAddNonPKColumnWhenlastPKIsVARBINARYOrARRAY() throws Exception { @Test public void testTableExists() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { ConnectionQueryServices cqs = - conn.unwrap(PhoenixConnection.class).getQueryServices(); + conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); String tableName = "randomTable"; // table never existed, still cqs.getTable() does not throw TNFE Table randomTable = cqs.getTable(Bytes.toBytes(tableName)); @@ -1735,7 +1736,7 @@ public void testTableExists() throws Exception { @Test public void testAlterTableWithColumnQualifiers() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); String ddl = "CREATE TABLE \"" + tableName + "\"(K VARCHAR NOT NULL PRIMARY KEY, " + @@ -1749,7 +1750,7 @@ public void testAlterTableWithColumnQualifiers() throws Exception { String addDdl = "ALTER TABLE \"" + tableName + "\" ADD CHAR1 char(10)"; conn.createStatement().execute(addDdl); - PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pconn = conn.unwrap(PhoenixMonitoredConnection.class); PTable table = pconn.getTable(new PTableKey(null, tableName)); QualifierEncodingScheme encodingScheme = table.getEncodingScheme(); @@ -1779,12 +1780,12 @@ public void testAlterTableWithColumnQualifiers() throws Exception { */ @Test public void testChangePropertiesUpdatesLASTDDLTimestamp() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String ddl = "CREATE TABLE " + dataTableFullName + " (a_string varchar not null, a_binary VARCHAR not null, col1 integer" + " CONSTRAINT pk PRIMARY KEY (a_string, a_binary)) " + tableDDLOptions; conn.createStatement().execute(ddl); - PhoenixConnection phxConn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection phxConn = conn.unwrap(PhoenixMonitoredConnection.class); PTable table = phxConn.getTable(new PTableKey(phxConn.getTenantId(), dataTableFullName)); long oldLastDDLTimestamp = table.getLastDDLTimestamp(); LOGGER.info("Last DDL timestamp before changing property: " + oldLastDDLTimestamp); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java index 36344a21d01..beeb903bbd0 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableWithViewsIT.java @@ -19,6 +19,7 @@ import static org.apache.phoenix.exception.SQLExceptionCode.CANNOT_MUTATE_TABLE; import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB; +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.assertNotEquals; @@ -48,6 +49,7 @@ import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.QueryConstants; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.ColumnNotFoundException; @@ -73,7 +75,6 @@ import org.apache.phoenix.thirdparty.com.google.common.base.Function; import org.apache.phoenix.thirdparty.com.google.common.collect.Lists; - @Category(NeedsOwnMiniClusterTest.class) @RunWith(Parameterized.class) public class AlterTableWithViewsIT extends SplitSystemCatalogIT { @@ -132,8 +133,8 @@ private String generateDDL(String options, String format) { @Test public void testAddNewColumnsToBaseTableWithViews() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); - Connection viewConn = isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1) : conn ) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Connection viewConn = isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES)) : conn ) { String tableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String viewOfTable = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); @@ -160,8 +161,8 @@ public void testAddNewColumnsToBaseTableWithViews() throws Exception { @Test public void testAlterPropertiesOfParentTable() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); - Connection viewConn = isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1) : conn ) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Connection viewConn = isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES)) : conn ) { String tableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String viewOfTable1 = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); String viewOfTable2 = SchemaUtil.getTableName(SCHEMA3, generateUniqueName()); @@ -178,9 +179,9 @@ public void testAlterPropertiesOfParentTable() throws Exception { PName tenantId = isMultiTenant ? PNameFactory.newName(TENANT1) : null; // Initially all property values should be the same for the base table and its views - PTable table = conn.unwrap(PhoenixConnection.class).getTable(new PTableKey(null, tableName)); - PTable viewTable1 = viewConn.unwrap(PhoenixConnection.class).getTable(new PTableKey(tenantId, viewOfTable1)); - PTable viewTable2 = viewConn.unwrap(PhoenixConnection.class).getTable(new PTableKey(tenantId, viewOfTable2)); + PTable table = conn.unwrap(PhoenixMonitoredConnection.class).getTable(new PTableKey(null, tableName)); + PTable viewTable1 = viewConn.unwrap(PhoenixMonitoredConnection.class).getTable(new PTableKey(tenantId, viewOfTable1)); + PTable viewTable2 = viewConn.unwrap(PhoenixMonitoredConnection.class).getTable(new PTableKey(tenantId, viewOfTable2)); assertFalse(table.isImmutableRows()); assertFalse(viewTable1.isImmutableRows()); assertFalse(viewTable2.isImmutableRows()); @@ -196,7 +197,7 @@ public void testAlterPropertiesOfParentTable() throws Exception { + " SET UPDATE_CACHE_FREQUENCY=1, USE_STATS_FOR_PARALLELIZATION=false"); // query the view to force the table cache to be updated viewConn.createStatement().execute("SELECT * FROM "+viewOfTable2); - viewTable2 = viewConn.unwrap(PhoenixConnection.class).getTable(new PTableKey(tenantId, viewOfTable2)); + viewTable2 = viewConn.unwrap(PhoenixMonitoredConnection.class).getTable(new PTableKey(tenantId, viewOfTable2)); assertEquals(1, viewTable2.getUpdateCacheFrequency()); assertFalse(viewTable2.useStatsForParallelization()); @@ -208,9 +209,9 @@ public void testAlterPropertiesOfParentTable() throws Exception { // query the views to force the table cache to be updated viewConn.createStatement().execute("SELECT * FROM "+viewOfTable1); viewConn.createStatement().execute("SELECT * FROM "+viewOfTable2); - table = conn.unwrap(PhoenixConnection.class).getTable(new PTableKey(null, tableName)); - viewTable1 = viewConn.unwrap(PhoenixConnection.class).getTable(new PTableKey(tenantId, viewOfTable1)); - viewTable2 = viewConn.unwrap(PhoenixConnection.class).getTable(new PTableKey(tenantId, viewOfTable2)); + table = conn.unwrap(PhoenixMonitoredConnection.class).getTable(new PTableKey(null, tableName)); + viewTable1 = viewConn.unwrap(PhoenixMonitoredConnection.class).getTable(new PTableKey(tenantId, viewOfTable1)); + viewTable2 = viewConn.unwrap(PhoenixMonitoredConnection.class).getTable(new PTableKey(tenantId, viewOfTable2)); assertTrue(table.isImmutableRows()); assertTrue(viewTable1.isImmutableRows()); assertTrue(viewTable2.isImmutableRows()); @@ -250,9 +251,9 @@ public void testAlterPropertiesOfParentTable() throws Exception { @Test public void testCreateViewWithPropsMaintainsOwnProps() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection viewConn = isMultiTenant ? - DriverManager.getConnection(TENANT_SPECIFIC_URL1) : conn) { + DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES)) : conn) { String tableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String viewOfTable1 = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); String viewOfTable2 = SchemaUtil.getTableName(SCHEMA3, generateUniqueName()); @@ -272,11 +273,11 @@ public void testCreateViewWithPropsMaintainsOwnProps() throws Exception { // Initially, property values not specified during view creation should be the same for // the base table and its views those specified should have corresponding values - PTable table = conn.unwrap(PhoenixConnection.class) + PTable table = conn.unwrap(PhoenixMonitoredConnection.class) .getTable(new PTableKey(null, tableName)); - PTable viewTable1 = viewConn.unwrap(PhoenixConnection.class) + PTable viewTable1 = viewConn.unwrap(PhoenixMonitoredConnection.class) .getTable(new PTableKey(tenantId, viewOfTable1)); - PTable viewTable2 = viewConn.unwrap(PhoenixConnection.class) + PTable viewTable2 = viewConn.unwrap(PhoenixMonitoredConnection.class) .getTable(new PTableKey(tenantId, viewOfTable2)); assertEquals(2, table.getUpdateCacheFrequency()); assertEquals(7, viewTable1.getUpdateCacheFrequency()); @@ -292,11 +293,11 @@ public void testCreateViewWithPropsMaintainsOwnProps() throws Exception { // query the views to force the table cache to be updated viewConn.createStatement().execute("SELECT * FROM " + viewOfTable1); viewConn.createStatement().execute("SELECT * FROM " + viewOfTable2); - table = conn.unwrap(PhoenixConnection.class) + table = conn.unwrap(PhoenixMonitoredConnection.class) .getTable(new PTableKey(null, tableName)); - viewTable1 = viewConn.unwrap(PhoenixConnection.class) + viewTable1 = viewConn.unwrap(PhoenixMonitoredConnection.class) .getTable(new PTableKey(tenantId, viewOfTable1)); - viewTable2 = viewConn.unwrap(PhoenixConnection.class) + viewTable2 = viewConn.unwrap(PhoenixMonitoredConnection.class) .getTable(new PTableKey(tenantId, viewOfTable2)); assertEquals(3, table.getUpdateCacheFrequency()); // The updated property value is only propagated to the view in which we did not specify @@ -311,8 +312,8 @@ public void testCreateViewWithPropsMaintainsOwnProps() throws Exception { @Test public void testDropColumnsFromBaseTableWithView() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); - Connection viewConn = isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1) : conn ) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Connection viewConn = isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES)) : conn ) { String tableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String viewOfTable = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); @@ -342,8 +343,8 @@ public void testDropColumnsFromBaseTableWithView() throws Exception { @Test public void testAddExistingViewColumnToBaseTableWithViews() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); - Connection viewConn = isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1) : conn ) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Connection viewConn = isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES)) : conn ) { conn.setAutoCommit(false); viewConn.setAutoCommit(false); String tableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); @@ -462,7 +463,7 @@ public void testAddExistingViewColumnToBaseTableWithViews() throws Exception { // the base column count and ordinal positions of columns is updated in the ptable (at read time) PName tenantId = isMultiTenant ? PNameFactory.newName(TENANT1) : null; - PTable view = viewConn.unwrap(PhoenixConnection.class).getTable(new PTableKey(tenantId, viewOfTable)); + PTable view = viewConn.unwrap(PhoenixMonitoredConnection.class).getTable(new PTableKey(tenantId, viewOfTable)); assertBaseColumnCount(4, view.getBaseColumnCount()); assertColumnsMatch(view.getColumns(), "ID", "COL1", "COL2", "COL3", "VIEW_COL4", "VIEW_COL2", "VIEW_COL1", "VIEW_COL3", "VIEW_COL5", "VIEW_COL6"); } @@ -471,8 +472,8 @@ public void testAddExistingViewColumnToBaseTableWithViews() throws Exception { @Test public void testAddExistingViewPkColumnToBaseTableWithViews() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); - Connection viewConn = isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1) : conn ) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Connection viewConn = isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES)) : conn ) { conn.setAutoCommit(false); viewConn.setAutoCommit(false); String tableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); @@ -584,15 +585,15 @@ public void testAddExistingViewPkColumnToBaseTableWithViews() throws Exception { // the base column count is updated in the ptable PName tenantId = isMultiTenant ? PNameFactory.newName(TENANT1) : null; PTable view = viewConn.unwrap(PhoenixConnection.class).getTableNoCache(viewOfTable.toUpperCase()); - view = viewConn.unwrap(PhoenixConnection.class).getTable(new PTableKey(tenantId, viewOfTable)); + view = viewConn.unwrap(PhoenixMonitoredConnection.class).getTable(new PTableKey(tenantId, viewOfTable)); assertBaseColumnCount(3, view.getBaseColumnCount()); } } @Test public void testAddExistingViewPkColumnToBaseTableWithMultipleViews() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); - Connection viewConn = isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1) : conn ) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Connection viewConn = isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES)) : conn ) { String tableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String viewOfTable1 = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); String viewOfTable2 = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); @@ -652,9 +653,9 @@ public void testAddExistingViewPkColumnToBaseTableWithMultipleViews() throws Exc @Test public void testAddExistingViewPkColumnToBaseTableWithMultipleViewsHavingSamePks() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); - Connection viewConn = isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1) : conn; - Connection viewConn2 = isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1) : conn) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Connection viewConn = isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES)) : conn; + Connection viewConn2 = isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES)) : conn) { conn.setAutoCommit(false); viewConn.setAutoCommit(false); viewConn2.setAutoCommit(false); @@ -759,7 +760,7 @@ public void testAddExistingViewPkColumnToBaseTableWithMultipleViewsHavingSamePks assertFalse(rs.next()); // the column count is updated in the base table - PTable table = conn.unwrap(PhoenixConnection.class).getTable(new PTableKey(null, tableName)); + PTable table = conn.unwrap(PhoenixMonitoredConnection.class).getTable(new PTableKey(null, tableName)); assertColumnsMatch(table.getColumns(), "ID", "COL1", "COL2", "VIEW_COL1", "VIEW_COL2"); } } @@ -823,9 +824,9 @@ public void testAlteringViewThatHasChildViews() throws Exception { String baseTable = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String childView = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); String grandChildView = SchemaUtil.getTableName(SCHEMA4, generateUniqueName()); - try (PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl()); - PhoenixConnection viewConn = isMultiTenant - ? (PhoenixConnection) DriverManager.getConnection(TENANT_SPECIFIC_URL1) + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + PhoenixMonitoredConnection viewConn = isMultiTenant + ? (PhoenixMonitoredConnection) DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES)) : conn) { String ddlFormat = "CREATE TABLE IF NOT EXISTS " + baseTable + " (" @@ -886,12 +887,12 @@ public void testDivergedViewsStayDiverged() throws Exception { String baseTable = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String view1 = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); String view2 = SchemaUtil.getTableName(SCHEMA3, generateUniqueName()); - try (PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl()); - PhoenixConnection viewConn = isMultiTenant - ? (PhoenixConnection) DriverManager.getConnection(TENANT_SPECIFIC_URL1) + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + PhoenixMonitoredConnection viewConn = isMultiTenant + ? (PhoenixMonitoredConnection) DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES)) : conn ; - PhoenixConnection viewConn2 = isMultiTenant - ? (PhoenixConnection) DriverManager.getConnection(TENANT_SPECIFIC_URL2) + PhoenixMonitoredConnection viewConn2 = isMultiTenant + ? (PhoenixMonitoredConnection) DriverManager.getConnection(TENANT_SPECIFIC_URL2, PropertiesUtil.deepCopy(TEST_PROPERTIES)) : conn) { String ddlFormat = "CREATE TABLE IF NOT EXISTS " + baseTable + " (" + " %s PK1 VARCHAR NOT NULL, V0 VARCHAR, V1 VARCHAR, V2 VARCHAR " @@ -991,10 +992,10 @@ public void testDivergedViewsStayDiverged() throws Exception { @Test public void testMakeBaseTableTransactional() throws Exception { - Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.TRANSACTIONS_ENABLED, Boolean.TRUE.toString()); try (Connection conn = DriverManager.getConnection(getUrl(), props); - Connection viewConn = isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1) : conn ) { + Connection viewConn = isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES)) : conn ) { String baseTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String viewOfTable = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); @@ -1011,17 +1012,17 @@ public void testMakeBaseTableTransactional() throws Exception { assertTableDefinition(viewConn, viewOfTable, PTableType.VIEW, baseTableName, 0, 5, 3, true, "ID", "COL1", "COL2", "VIEW_COL1", "VIEW_COL2"); PName tenantId = isMultiTenant ? PNameFactory.newName(TENANT1) : null; - PhoenixConnection phoenixConn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection phoenixConn = conn.unwrap(PhoenixMonitoredConnection.class); Table table = phoenixConn.getQueryServices().getTable(Bytes.toBytes(baseTableName)); assertFalse(phoenixConn.getTable(new PTableKey(null, baseTableName)).isTransactional()); - assertFalse(viewConn.unwrap(PhoenixConnection.class).getTable(new PTableKey(tenantId, viewOfTable)).isTransactional()); + assertFalse(viewConn.unwrap(PhoenixMonitoredConnection.class).getTable(new PTableKey(tenantId, viewOfTable)).isTransactional()); } } @Test public void testAlterTablePropertyOnView() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); - Connection viewConn = isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1) : conn ) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Connection viewConn = isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES)) : conn ) { String baseTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String viewOfTable = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); @@ -1044,7 +1045,7 @@ public void testAlterTablePropertyOnView() throws Exception { viewConn.createStatement().execute("ALTER VIEW " + viewOfTable + " SET UPDATE_CACHE_FREQUENCY = 100"); viewConn.createStatement().execute("SELECT * FROM "+ viewOfTable); PName tenantId = isMultiTenant ? PNameFactory.newName(TENANT1) : null; - assertEquals(100, viewConn.unwrap(PhoenixConnection.class).getTable(new PTableKey(tenantId, viewOfTable)).getUpdateCacheFrequency()); + assertEquals(100, viewConn.unwrap(PhoenixMonitoredConnection.class).getTable(new PTableKey(tenantId, viewOfTable)).getUpdateCacheFrequency()); try { viewConn.createStatement().execute("ALTER VIEW " + viewOfTable + " SET APPEND_ONLY_SCHEMA = true"); @@ -1057,8 +1058,8 @@ public void testAlterTablePropertyOnView() throws Exception { @Test public void testAlterAppendOnlySchema() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); - Connection viewConn = isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1) : conn ) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Connection viewConn = isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES)) : conn ) { String baseTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String viewOfTable = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); @@ -1071,11 +1072,11 @@ public void testAlterAppendOnlySchema() throws Exception { ddl = "CREATE VIEW " + viewOfTable + " AS SELECT * FROM " + baseTableName; viewConn.createStatement().execute(ddl); - PhoenixConnection phoenixConn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection phoenixConn = conn.unwrap(PhoenixMonitoredConnection.class); PTable table = phoenixConn.getTable(new PTableKey(null, baseTableName)); PName tenantId = isMultiTenant ? PNameFactory.newName(TENANT1) : null; assertFalse(table.isAppendOnlySchema()); - PTable viewTable = viewConn.unwrap(PhoenixConnection.class).getTable(new PTableKey(tenantId, viewOfTable)); + PTable viewTable = viewConn.unwrap(PhoenixMonitoredConnection.class).getTable(new PTableKey(tenantId, viewOfTable)); assertFalse(viewTable.isAppendOnlySchema()); try { @@ -1089,18 +1090,18 @@ public void testAlterAppendOnlySchema() throws Exception { conn.createStatement().execute("ALTER TABLE " + baseTableName + " SET APPEND_ONLY_SCHEMA = true"); viewConn.createStatement().execute("SELECT * FROM "+viewOfTable); - phoenixConn = conn.unwrap(PhoenixConnection.class); + phoenixConn = conn.unwrap(PhoenixMonitoredConnection.class); table = phoenixConn.getTable(new PTableKey(null, baseTableName)); assertTrue(table.isAppendOnlySchema()); - viewTable = viewConn.unwrap(PhoenixConnection.class).getTable(new PTableKey(tenantId, viewOfTable)); + viewTable = viewConn.unwrap(PhoenixMonitoredConnection.class).getTable(new PTableKey(tenantId, viewOfTable)); assertTrue(viewTable.isAppendOnlySchema()); } } @Test public void testDroppingIndexedColDropsViewIndex() throws Exception { - try (Connection conn =DriverManager.getConnection(getUrl()); - Connection viewConn = isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1) : conn ) { + try (Connection conn =DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Connection viewConn = isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES)) : conn ) { String tableWithView = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String viewOfTable = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); String viewSchemaName = SchemaUtil.getSchemaNameFromFullName(viewOfTable); @@ -1143,7 +1144,7 @@ public void testDroppingIndexedColDropsViewIndex() throws Exception { viewConn.commit(); // verify the index was created - PhoenixConnection pconn = viewConn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pconn = viewConn.unwrap(PhoenixMonitoredConnection.class); PName tenantId = isMultiTenant ? PNameFactory.newName(TENANT1) : null; PTable view = pconn.getTable(new PTableKey(tenantId, viewOfTable )); PTable viewIndex = pconn.getTable(new PTableKey(tenantId, fullNameViewIndex1 )); @@ -1179,7 +1180,7 @@ public void testDroppingIndexedColDropsViewIndex() throws Exception { } catch (TableNotFoundException e) { } - pconn = viewConn.unwrap(PhoenixConnection.class); + pconn = viewConn.unwrap(PhoenixMonitoredConnection.class); view = pconn.getTableNoCache(viewOfTable); assertEquals("Unexpected number of indexes ", 1, view.getIndexes().size()); assertEquals("Unexpected index ", fullNameViewIndex2 , view.getIndexes().get(0).getName().getString()); @@ -1187,15 +1188,20 @@ public void testDroppingIndexedColDropsViewIndex() throws Exception { try { viewIndex = pconn.getTableNoCache(fullNameViewIndex1); fail("View index should have been dropped"); - } catch (TableNotFoundException e) { + } catch (Exception e) { + if(e instanceof SQLException && e.getCause() instanceof TableNotFoundException) { + //expected exception + } else if(e instanceof TableNotFoundException) { + //expected exception + } } // verify that the physical index view table is *not* dropped - conn.unwrap(PhoenixConnection.class).getQueryServices().getTableDescriptor(viewIndexPhysicalTable); + conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getTableDescriptor(viewIndexPhysicalTable); // scan the physical table and verify there is a single row for the second local index Scan scan = new Scan(); - Table table = conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(viewIndexPhysicalTable); + Table table = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getTable(viewIndexPhysicalTable); ResultScanner results = table.getScanner(scan); Result result = results.next(); assertNotNull(result); @@ -1210,7 +1216,7 @@ public void testDroppingIndexedColDropsViewIndex() throws Exception { @Test public void testAddThenDropColumnTableDDLTimestamp() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); String schemaName = SCHEMA1; String dataTableName = "T_" + generateUniqueName(); String viewName = "V_" + generateUniqueName(); @@ -1282,7 +1288,7 @@ public void testLastDDLTimestampForDivergedViews() throws Exception { String tableColumnAddDDL = "ALTER TABLE " + dataTableFullName + " ADD COL5 varchar" + "(50) NULL"; String tableColumnDropDDL = "ALTER TABLE " + dataTableFullName + " DROP COLUMN COL3 "; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute(tableDDL); long tableDDLTimestamp = CreateTableIT.getLastDDLTimestamp(conn, dataTableFullName); conn.createStatement().execute(viewDDL); @@ -1319,7 +1325,7 @@ public void testLastDDLTimestampForDivergedViews() throws Exception { @Test public void testLastDDLTimestampWithChildViews() throws Exception { Assume.assumeTrue(isMultiTenant); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); String schemaName = SCHEMA1; String dataTableName = "T_" + generateUniqueName(); String globalViewName = "V_" + generateUniqueName(); @@ -1344,8 +1350,7 @@ public void testLastDDLTimestampWithChildViews() throws Exception { long startTS = EnvironmentEdgeManager.currentTimeMillis(); long tableDDLTimestamp, globalViewDDLTimestamp; - - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute(tableDDL); conn.createStatement().execute(globalViewDDL); tableDDLTimestamp = CreateTableIT.getLastDDLTimestamp(conn, dataTableFullName); @@ -1358,7 +1363,7 @@ public void testLastDDLTimestampWithChildViews() throws Exception { // First, check that adding a child view to the base table didn't change the base table's // timestamp, and that adding a child tenant view to the global view didn't change the // global view's timestamp - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { long newTableDDLTimestamp = CreateTableIT.getLastDDLTimestamp(conn, dataTableFullName); assertEquals(tableDDLTimestamp, newTableDDLTimestamp); @@ -1397,7 +1402,7 @@ public void testLastDDLTimestampWithChildViews() throws Exception { String tableColumnAddDDL = "ALTER TABLE " + dataTableFullName + " ADD COL4 varchar" + "(50) " + "NULL "; String tableColumnDropDDL = "ALTER TABLE " + dataTableFullName + " DROP COLUMN COL4 "; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute(tableColumnAddDDL); tableDDLTimestamp = CreateTableIT.getLastDDLTimestamp(conn, dataTableFullName); try (Connection tenantConn = DriverManager.getConnection(getUrl(), props)) { @@ -1426,7 +1431,7 @@ public void testLastDDLTimestampWithChildViews() throws Exception { String globalViewColumnAddDDL = "ALTER VIEW " + globalViewFullName + " ADD COL5 varchar" + "(50) " + "NULL "; String globalViewColumnDropDDL = "ALTER VIEW " + globalViewFullName + " DROP COLUMN COL5 "; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute(globalViewColumnAddDDL); globalViewDDLTimestamp = CreateTableIT.getLastDDLTimestamp(conn, globalViewFullName); long newTableDDLTimestamp = CreateTableIT.getLastDDLTimestamp(conn, @@ -1458,13 +1463,13 @@ public void testLastDDLTimestampWithChildViews() throws Exception { @Test public void testCreateViewSchemaVersion() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); final String schemaName = generateUniqueName(); final String tableName = generateUniqueName(); final String viewName = generateUniqueName(); final String dataTableFullName = SchemaUtil.getTableName(schemaName, tableName); final String viewFullName = SchemaUtil.getTableName(schemaName, viewName); - try (PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl(), + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), props)) { String oldVersion = "V1.0"; CreateTableIT.testCreateTableSchemaVersionAndTopicNameHelper(conn, schemaName, tableName, oldVersion, null); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AppendOnlySchemaIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AppendOnlySchemaIT.java index dba8c650451..58261b1b739 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AppendOnlySchemaIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AppendOnlySchemaIT.java @@ -46,8 +46,8 @@ import org.apache.hadoop.hbase.client.Mutation; import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.exception.SQLExceptionCode; -import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixEmbeddedDriver; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.ConnectionQueryServices; import org.apache.phoenix.schema.ColumnAlreadyExistsException; import org.apache.phoenix.schema.PColumn; @@ -62,20 +62,17 @@ import org.junit.experimental.categories.Category; import org.mockito.AdditionalMatchers; import org.mockito.Mockito; - @Category(ParallelStatsDisabledTest.class) public class AppendOnlySchemaIT extends ParallelStatsDisabledIT { private void testTableWithSameSchema(boolean notExists, boolean sameClient) throws Exception { - // use a spyed ConnectionQueryServices so we can verify calls to getTable ConnectionQueryServices connectionQueryServices = - Mockito.spy(driver.getConnectionQueryServices(getUrl(), + Mockito.spy(driver.getConnectionQueryServices(getActiveUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.putAll(PhoenixEmbeddedDriver.DEFAULT_PROPS.asMap()); - try (Connection conn1 = connectionQueryServices.connect(getUrl(), props); Connection conn2 = sameClient ? conn1 : connectionQueryServices.connect(getUrl(), props)) { @@ -239,7 +236,7 @@ private void testAddColumns(boolean sameClient) throws Exception { // verify the two columns were added correctly PTable table = - conn2.unwrap(PhoenixConnection.class).getTable(new PTableKey(null, viewName)); + conn2.unwrap(PhoenixMonitoredConnection.class).getTable(new PTableKey(null, viewName)); List pkColumns = table.getPKColumns(); assertEquals(3,table.getPKColumns().size()); // even though the second create view statement changed the order of the pk, the original order is maintained @@ -319,7 +316,7 @@ public void testValidateAttributes() throws Exception { + " APPEND_ONLY_SCHEMA = true, UPDATE_CACHE_FREQUENCY=1000"); conn.createStatement().execute( "create view IF NOT EXISTS " + viewName + " (val1 integer) AS SELECT * FROM " + tableName); - PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pconn = conn.unwrap(PhoenixMonitoredConnection.class); PTable view = pconn.getTable(new PTableKey(pconn.getTenantId(), viewName)); assertEquals(true, view.isAppendOnlySchema()); assertEquals(1000, view.getUpdateCacheFrequency()); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArithmeticQueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArithmeticQueryIT.java index d6acd099bd7..608a2d2d4d1 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArithmeticQueryIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArithmeticQueryIT.java @@ -39,7 +39,6 @@ import org.apache.phoenix.thirdparty.com.google.common.primitives.Doubles; import org.apache.phoenix.thirdparty.com.google.common.primitives.Floats; - @Category(ParallelStatsDisabledTest.class) public class ArithmeticQueryIT extends ParallelStatsDisabledIT { @@ -745,7 +744,7 @@ private String initIntegerTable(Connection conn) throws SQLException { @Test public void testOrderOfOperationsAdditionSubtraction() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initIntegerTable(conn); ResultSet rs; @@ -768,7 +767,7 @@ public void testOrderOfOperationsAdditionSubtraction() throws Exception { @Test public void testOrderOfOperationsAdditionMultiplication() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initIntegerTable(conn); ResultSet rs; @@ -791,7 +790,7 @@ public void testOrderOfOperationsAdditionMultiplication() throws Exception { @Test public void testOrderOfOperationsAdditionDivision() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initIntegerTable(conn); ResultSet rs; @@ -814,7 +813,7 @@ public void testOrderOfOperationsAdditionDivision() throws Exception { @Test public void testOrderOfOperationsAdditionModulus() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initIntegerTable(conn); ResultSet rs; @@ -837,7 +836,7 @@ public void testOrderOfOperationsAdditionModulus() throws Exception { @Test public void testOrderOfOperationsSubtrationMultiplication() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initIntegerTable(conn); ResultSet rs; @@ -860,7 +859,7 @@ public void testOrderOfOperationsSubtrationMultiplication() throws Exception { @Test public void testOrderOfOperationsSubtractionDivision() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initIntegerTable(conn); ResultSet rs; @@ -883,7 +882,7 @@ public void testOrderOfOperationsSubtractionDivision() throws Exception { @Test public void testOrderOfOperationsSubtractionModulus() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initIntegerTable(conn); ResultSet rs; @@ -906,7 +905,7 @@ public void testOrderOfOperationsSubtractionModulus() throws Exception { @Test public void testOrderOfOperationsMultiplicationDivision() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initIntegerTable(conn); ResultSet rs; @@ -929,7 +928,7 @@ public void testOrderOfOperationsMultiplicationDivision() throws Exception { @Test public void testOrderOfOperationsMultiplicationModulus() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initIntegerTable(conn); ResultSet rs; @@ -952,7 +951,7 @@ public void testOrderOfOperationsMultiplicationModulus() throws Exception { @Test public void testOrderOfOperationsDivisionModulus() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initIntegerTable(conn); ResultSet rs; @@ -975,7 +974,7 @@ public void testOrderOfOperationsDivisionModulus() throws Exception { @Test public void testCastingOnConstantAddInArithmeticEvaluation() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String testTable = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + testTable + " (k1 INTEGER NOT NULL, v1 INTEGER CONSTRAINT pk PRIMARY KEY (k1))"; @@ -993,7 +992,7 @@ public void testCastingOnConstantAddInArithmeticEvaluation() throws Exception { @Test public void testCastingOnConstantSubInArithmeticEvaluation() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String testTable = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + testTable + " (k1 INTEGER NOT NULL, v1 INTEGER CONSTRAINT pk PRIMARY KEY (k1))"; @@ -1010,7 +1009,7 @@ public void testCastingOnConstantSubInArithmeticEvaluation() throws Exception { @Test public void testFloatingPointUpsert() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String test = generateUniqueName(); String ddl = "CREATE TABLE " + test + " (id VARCHAR not null primary key, name VARCHAR, lat FLOAT)"; @@ -1026,7 +1025,7 @@ public void testFloatingPointUpsert() throws Exception { @Test public void testFloatingPointMultiplicationUpsert() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String test = generateUniqueName(); String ddl = "CREATE TABLE " + test + " (id VARCHAR not null primary key, name VARCHAR, lat FLOAT)"; @@ -1043,7 +1042,7 @@ public void testFloatingPointMultiplicationUpsert() throws Exception { @Test public void testSystemTableHasDoubleForExponentialNumber() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String test = generateUniqueName(); String ddl = "CREATE TABLE " + test + " (id VARCHAR not null primary key, num FLOAT)"; conn.createStatement().execute(ddl); @@ -1077,7 +1076,7 @@ public void testDoubleWithExponentialNotation() throws Exception { } private ResultSet createTableWithValues(String[] values, String valueType) throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String test = generateUniqueName(); StringBuilder ddl = new StringBuilder( "CREATE TABLE " + test + " (id VARCHAR not null primary key"); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/Array1IT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/Array1IT.java index f5e95877833..0061c9caabc 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/Array1IT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/Array1IT.java @@ -42,7 +42,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; import org.apache.phoenix.thirdparty.com.google.common.primitives.Floats; - @Category(ParallelStatsDisabledTest.class) public class Array1IT extends ArrayIT { private void assertArrayGetString(ResultSet rs, int arrayIndex, Array expectedArray, String expectedString) @@ -87,7 +86,7 @@ private static String createSimpleTableWithArray(String url, byte[][] bs, Object } private static void initSimpleArrayTable(String tableName, String tenantId, Date date, boolean useNull) throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); try { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/Array2IT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/Array2IT.java index 6a533d4b08d..760b32d081b 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/Array2IT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/Array2IT.java @@ -40,7 +40,6 @@ import org.apache.phoenix.util.StringUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class Array2IT extends ArrayIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/Array3IT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/Array3IT.java index 7dde87bfbce..40fdd152dc1 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/Array3IT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/Array3IT.java @@ -33,7 +33,6 @@ import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class Array3IT extends ArrayIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayAppendFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayAppendFunctionIT.java index b86bac96224..9f54d2634ee 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayAppendFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayAppendFunctionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +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; @@ -29,9 +30,9 @@ import java.sql.SQLException; import org.apache.phoenix.schema.TypeMismatchException; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class ArrayAppendFunctionIT extends ParallelStatsDisabledIT { private String initTables(Connection conn) throws Exception { @@ -79,7 +80,7 @@ private String initTablesDesc(Connection conn, String type, String val) throws E @Test public void testEmptyArrayModification() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -135,7 +136,7 @@ public void testEmptyArrayModification() throws Exception { @Test public void testUpsertEmptyArrayModification() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -153,7 +154,7 @@ public void testUpsertEmptyArrayModification() throws Exception { @Test public void testArrayAppendFunctionVarchar() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -170,7 +171,7 @@ public void testArrayAppendFunctionVarchar() throws Exception { @Test public void testUpsertArrayAppendFunctionVarchar() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); conn.createStatement().execute("UPSERT INTO " + tableName + " (region_name,varchars) SELECT region_name,ARRAY_APPEND(varchars,'34567') as varchars FROM " + tableName+ " WHERE region_name = 'SF Bay Area'"); @@ -190,7 +191,7 @@ public void testUpsertArrayAppendFunctionVarchar() throws Exception { @Test public void testArrayAppendFunctionInteger() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -207,7 +208,7 @@ public void testArrayAppendFunctionInteger() throws Exception { @Test public void testArrayAppendFunctionDouble() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -224,7 +225,7 @@ public void testArrayAppendFunctionDouble() throws Exception { @Test public void testArrayAppendFunctionDouble2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -241,7 +242,7 @@ public void testArrayAppendFunctionDouble2() throws Exception { @Test public void testArrayAppendFunctionBigint() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; rs = conn.createStatement().executeQuery("SELECT ARRAY_APPEND(bigints,1112) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); @@ -257,7 +258,7 @@ public void testArrayAppendFunctionBigint() throws Exception { @Test public void testArrayAppendFunctionChar() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; rs = conn.createStatement().executeQuery("SELECT ARRAY_APPEND(chars,'fac') FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); @@ -273,7 +274,7 @@ public void testArrayAppendFunctionChar() throws Exception { @Test(expected = TypeMismatchException.class) public void testArrayAppendFunctionIntToCharArray() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -282,7 +283,7 @@ public void testArrayAppendFunctionIntToCharArray() throws Exception { @Test(expected = TypeMismatchException.class) public void testArrayAppendFunctionVarcharToIntegerArray() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -292,7 +293,7 @@ public void testArrayAppendFunctionVarcharToIntegerArray() throws Exception { @Test(expected = SQLException.class) public void testArrayAppendFunctionChar2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; rs = conn.createStatement().executeQuery("SELECT ARRAY_APPEND(chars,'facfacfacfacfacfacfac') FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); @@ -302,7 +303,7 @@ public void testArrayAppendFunctionChar2() throws Exception { @Test public void testArrayAppendFunctionIntegerToDoubleArray() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -319,7 +320,7 @@ public void testArrayAppendFunctionIntegerToDoubleArray() throws Exception { @Test public void testArrayAppendFunctionWithNestedFunctions1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -336,7 +337,7 @@ public void testArrayAppendFunctionWithNestedFunctions1() throws Exception { @Test public void testArrayAppendFunctionWithNestedFunctions2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -353,7 +354,7 @@ public void testArrayAppendFunctionWithNestedFunctions2() throws Exception { @Test public void testArrayAppendFunctionWithNestedFunctions3() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -370,7 +371,7 @@ public void testArrayAppendFunctionWithNestedFunctions3() throws Exception { @Test public void testArrayAppendFunctionWithUpsert1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + " (region_name VARCHAR PRIMARY KEY,varchars VARCHAR[])"; conn.createStatement().execute(ddl); @@ -393,7 +394,7 @@ public void testArrayAppendFunctionWithUpsert1() throws Exception { @Test public void testArrayAppendFunctionWithUpsert2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + " (region_name VARCHAR PRIMARY KEY,integers INTEGER[])"; @@ -417,7 +418,7 @@ public void testArrayAppendFunctionWithUpsert2() throws Exception { @Test public void testArrayAppendFunctionWithUpsert3() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + " (region_name VARCHAR PRIMARY KEY,doubles DOUBLE[])"; @@ -441,7 +442,7 @@ public void testArrayAppendFunctionWithUpsert3() throws Exception { @Test public void testArrayAppendFunctionWithUpsertSelect1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String sourceTableName = generateUniqueName(); String targetTableName = generateUniqueName(); @@ -482,7 +483,7 @@ public void testArrayAppendFunctionWithUpsertSelect1() throws Exception { @Test public void testArrayAppendFunctionWithUpsertSelect2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String sourceTableName = generateUniqueName(); String targetTableName = generateUniqueName(); @@ -522,7 +523,7 @@ public void testArrayAppendFunctionWithUpsertSelect2() throws Exception { @Test public void testArrayAppendFunctionInWhere1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -535,7 +536,7 @@ public void testArrayAppendFunctionInWhere1() throws Exception { @Test public void testArrayAppendFunctionInWhere2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -548,7 +549,7 @@ public void testArrayAppendFunctionInWhere2() throws Exception { @Test public void testArrayAppendFunctionInWhere3() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -561,7 +562,7 @@ public void testArrayAppendFunctionInWhere3() throws Exception { @Test public void testArrayAppendFunctionInWhere4() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -574,7 +575,7 @@ public void testArrayAppendFunctionInWhere4() throws Exception { @Test public void testArrayAppendFunctionInWhere5() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -587,7 +588,7 @@ public void testArrayAppendFunctionInWhere5() throws Exception { @Test public void testArrayAppendFunctionInWhere6() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -600,7 +601,7 @@ public void testArrayAppendFunctionInWhere6() throws Exception { @Test public void testArrayAppendFunctionInWhere7() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -613,7 +614,7 @@ public void testArrayAppendFunctionInWhere7() throws Exception { @Test public void testArrayAppendFunctionVarcharWithNull() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -630,7 +631,7 @@ public void testArrayAppendFunctionVarcharWithNull() throws Exception { @Test public void testArrayAppendFunctionDoublesWithNull() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -647,7 +648,7 @@ public void testArrayAppendFunctionDoublesWithNull() throws Exception { @Test public void testArrayAppendFunctionCharsWithNull() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -664,7 +665,7 @@ public void testArrayAppendFunctionCharsWithNull() throws Exception { @Test public void testArrayAppendFunctionWithNull() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -681,7 +682,7 @@ public void testArrayAppendFunctionWithNull() throws Exception { @Test(expected = SQLException.class) public void testArrayAppendFunctionCharLimitCheck() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -698,7 +699,7 @@ public void testArrayAppendFunctionCharLimitCheck() throws Exception { @Test public void testArrayAppendFunctionIntegerDesc() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTablesDesc(conn, "INTEGER", "23"); ResultSet rs; @@ -716,7 +717,7 @@ public void testArrayAppendFunctionIntegerDesc() throws Exception { @Test public void testArrayAppendFunctionVarcharDesc() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTablesDesc(conn, "VARCHAR", "'e'"); ResultSet rs; @@ -733,7 +734,7 @@ public void testArrayAppendFunctionVarcharDesc() throws Exception { @Test public void testArrayAppendFunctionBigIntDesc() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTablesDesc(conn, "BIGINT", "1112"); ResultSet rs; rs = conn.createStatement().executeQuery("SELECT ARRAY_APPEND(bigints,pk) FROM " + tableName ); @@ -749,7 +750,7 @@ public void testArrayAppendFunctionBigIntDesc() throws Exception { @Test public void testArrayAppendFunctionBooleanDesc() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTablesDesc(conn, "BOOLEAN", "false"); ResultSet rs; rs = conn.createStatement().executeQuery("SELECT ARRAY_APPEND(bools,pk) FROM " + tableName ); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayConcatFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayConcatFunctionIT.java index 1775030470f..b281eecf398 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayConcatFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayConcatFunctionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +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; @@ -29,9 +30,9 @@ import java.sql.SQLException; import org.apache.phoenix.schema.TypeMismatchException; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class ArrayConcatFunctionIT extends ParallelStatsDisabledIT { @@ -58,7 +59,7 @@ private String initTables(Connection conn) throws Exception { @Test public void testArrayConcatFunctionVarchar() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -75,7 +76,7 @@ public void testArrayConcatFunctionVarchar() throws Exception { @Test public void testNullArrayConcat() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -97,7 +98,7 @@ public void testNullArrayConcat() throws Exception { @Test public void testArrayConcatFunctionInteger() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -114,7 +115,7 @@ public void testArrayConcatFunctionInteger() throws Exception { @Test public void testArrayConcatFunctionDouble() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -131,7 +132,7 @@ public void testArrayConcatFunctionDouble() throws Exception { @Test public void testArrayConcatFunctionDouble2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -148,7 +149,7 @@ public void testArrayConcatFunctionDouble2() throws Exception { @Test public void testArrayConcatFunctionBigint() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; rs = conn.createStatement().executeQuery("SELECT ARRAY_CAT(bigints,bigints) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); @@ -164,7 +165,7 @@ public void testArrayConcatFunctionBigint() throws Exception { @Test public void testArrayConcatFunctionChar() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; rs = conn.createStatement().executeQuery("SELECT ARRAY_CAT(chars,chars) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); @@ -180,7 +181,7 @@ public void testArrayConcatFunctionChar() throws Exception { @Test public void testArrayConcatFunctionChar3() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; rs = conn.createStatement().executeQuery("SELECT ARRAY_CAT(chars,chars2) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); @@ -196,7 +197,8 @@ public void testArrayConcatFunctionChar3() throws Exception { @Test(expected = TypeMismatchException.class) public void testArrayConcatFunctionIntToCharArray() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -205,7 +207,7 @@ public void testArrayConcatFunctionIntToCharArray() throws Exception { @Test(expected = TypeMismatchException.class) public void testArrayConcatFunctionVarcharToIntegerArray() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -215,7 +217,7 @@ public void testArrayConcatFunctionVarcharToIntegerArray() throws Exception { @Test(expected = SQLException.class) public void testArrayConcatFunctionChar2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; rs = conn.createStatement().executeQuery("SELECT ARRAY_CAT(chars,ARRAY['facfacfacfacfacfacfac','facfacfacfacfacfacfac']) FROM " + tableName + " WHERE region_name = 'SF Bay Area'"); @@ -225,7 +227,7 @@ public void testArrayConcatFunctionChar2() throws Exception { @Test public void testArrayConcatFunctionIntegerArrayToDoubleArray() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -242,7 +244,7 @@ public void testArrayConcatFunctionIntegerArrayToDoubleArray() throws Exception @Test public void testArrayConcatFunctionWithNestedFunctions1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -259,7 +261,7 @@ public void testArrayConcatFunctionWithNestedFunctions1() throws Exception { @Test public void testArrayConcatFunctionWithNestedFunctions2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -276,7 +278,7 @@ public void testArrayConcatFunctionWithNestedFunctions2() throws Exception { @Test public void testArrayConcatFunctionWithNestedFunctions3() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -293,7 +295,7 @@ public void testArrayConcatFunctionWithNestedFunctions3() throws Exception { @Test public void testArrayConcatFunctionWithUpsert1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + " (region_name VARCHAR PRIMARY KEY,varchars VARCHAR[])"; @@ -317,7 +319,7 @@ public void testArrayConcatFunctionWithUpsert1() throws Exception { @Test public void testArrayConcatFunctionWithUpsert2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + " (region_name VARCHAR PRIMARY KEY,integers INTEGER[])"; @@ -341,7 +343,7 @@ public void testArrayConcatFunctionWithUpsert2() throws Exception { @Test public void testArrayConcatFunctionWithUpsert3() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + " (region_name VARCHAR PRIMARY KEY,doubles DOUBLE[])"; @@ -365,7 +367,7 @@ public void testArrayConcatFunctionWithUpsert3() throws Exception { @Test public void testArrayConcatFunctionWithUpsertSelect1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String sourceTableName = generateUniqueName(); String targetTableName = generateUniqueName(); @@ -405,7 +407,7 @@ public void testArrayConcatFunctionWithUpsertSelect1() throws Exception { @Test public void testArrayConcatFunctionWithUpsertSelect2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String sourceTableName = generateUniqueName(); String targetTableName = generateUniqueName(); String ddl = "CREATE TABLE " + sourceTableName + " (region_name VARCHAR PRIMARY KEY,varchars VARCHAR[])"; @@ -444,7 +446,7 @@ public void testArrayConcatFunctionWithUpsertSelect2() throws Exception { @Test public void testArrayConcatFunctionInWhere1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -457,7 +459,7 @@ public void testArrayConcatFunctionInWhere1() throws Exception { @Test public void testArrayConcatFunctionInWhere2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -470,7 +472,7 @@ public void testArrayConcatFunctionInWhere2() throws Exception { @Test public void testArrayConcatFunctionInWhere3() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -483,7 +485,7 @@ public void testArrayConcatFunctionInWhere3() throws Exception { @Test public void testArrayConcatFunctionInWhere4() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -496,7 +498,7 @@ public void testArrayConcatFunctionInWhere4() throws Exception { @Test public void testArrayConcatFunctionInWhere5() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -509,7 +511,7 @@ public void testArrayConcatFunctionInWhere5() throws Exception { @Test public void testArrayConcatFunctionInWhere6() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -522,7 +524,7 @@ public void testArrayConcatFunctionInWhere6() throws Exception { @Test public void testArrayConcatFunctionInWhere7() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -535,7 +537,7 @@ public void testArrayConcatFunctionInWhere7() throws Exception { @Test public void testArrayConcatFunctionWithNulls1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -555,7 +557,7 @@ public void testArrayConcatFunctionWithNulls1() throws Exception { @Test public void testArrayConcatFunctionWithNulls2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -575,7 +577,7 @@ public void testArrayConcatFunctionWithNulls2() throws Exception { @Test public void testArrayConcatFunctionWithNulls3() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; @@ -595,7 +597,7 @@ public void testArrayConcatFunctionWithNulls3() throws Exception { @Test public void testArrayConcatFunctionWithNulls4() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initTables(conn); ResultSet rs; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayFillFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayFillFunctionIT.java index 8a7da7e4db1..ad03ec0295b 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayFillFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayFillFunctionIT.java @@ -18,6 +18,7 @@ package org.apache.phoenix.end2end; +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; @@ -32,10 +33,10 @@ import java.sql.Time; import java.sql.Timestamp; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { @@ -44,7 +45,7 @@ public class ArrayFillFunctionIT extends ParallelStatsDisabledIT { @Before public void initTable() throws Exception { tableName = generateUniqueName(); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String ddl = "CREATE TABLE " + tableName + " (region_name VARCHAR PRIMARY KEY,length1 INTEGER, length2 INTEGER,\"DATE\" DATE,\"time\" TIME,\"timestamp\" TIMESTAMP,\"varchar\" VARCHAR,\"integer\" INTEGER,\"double\" DOUBLE,\"bigint\" BIGINT,\"char\" CHAR(15),double1 DOUBLE,char1 CHAR(17),nullcheck INTEGER,chars2 CHAR(15)[], varchars2 VARCHAR[])"; conn.createStatement().execute(ddl); @@ -74,7 +75,7 @@ public void initTable() throws Exception { @Test public void testArrayFillFunctionVarchar() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery( @@ -91,7 +92,7 @@ public void testArrayFillFunctionVarchar() throws Exception { @Test public void testArrayFillFunctionInteger() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery( @@ -108,7 +109,7 @@ public void testArrayFillFunctionInteger() throws Exception { @Test public void testArrayFillFunctionDouble() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; @@ -126,7 +127,7 @@ public void testArrayFillFunctionDouble() throws Exception { @Test public void testArrayFillFunctionBigint() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; @@ -144,7 +145,7 @@ public void testArrayFillFunctionBigint() throws Exception { @Test public void testArrayFillFunctionChar() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; @@ -161,7 +162,7 @@ public void testArrayFillFunctionChar() throws Exception { @Test public void testArrayFillFunctionVarChar() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; @@ -178,7 +179,7 @@ public void testArrayFillFunctionVarChar() throws Exception { @Test public void testArrayFillFunctionDate() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; @@ -195,7 +196,7 @@ public void testArrayFillFunctionDate() throws Exception { @Test public void testArrayFillFunctionTime() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; @@ -212,7 +213,7 @@ public void testArrayFillFunctionTime() throws Exception { @Test public void testArrayFillFunctionTimestamp() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; @@ -229,7 +230,7 @@ public void testArrayFillFunctionTimestamp() throws Exception { @Test(expected = IllegalArgumentException.class) public void testArrayFillFunctionInvalidLength1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; @@ -247,7 +248,7 @@ public void testArrayFillFunctionInvalidLength1() throws Exception { @Test(expected = IllegalArgumentException.class) public void testArrayFillFunctionInvalidLength2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; @@ -265,7 +266,7 @@ public void testArrayFillFunctionInvalidLength2() throws Exception { @Test public void testArrayFillFunctionWithNestedFunctions1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; @@ -284,7 +285,7 @@ public void testArrayFillFunctionWithNestedFunctions1() throws Exception { @Test public void testArrayFillFunctionWithNestedFunctions2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; @@ -303,7 +304,7 @@ public void testArrayFillFunctionWithNestedFunctions2() throws Exception { @Test public void testArrayFillFunctionWithNestedFunctions3() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; @@ -322,7 +323,7 @@ public void testArrayFillFunctionWithNestedFunctions3() throws Exception { @Test public void testArrayFillFunctionWithUpsert1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String regions = generateUniqueName(); String ddl = @@ -349,7 +350,7 @@ public void testArrayFillFunctionWithUpsert1() throws Exception { @Test public void testArrayFillFunctionWithUpsert2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String regions = generateUniqueName(); String ddl = @@ -376,7 +377,7 @@ public void testArrayFillFunctionWithUpsert2() throws Exception { @Test public void testArrayFillFunctionWithUpsert3() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String regions = generateUniqueName(); String ddl = @@ -403,7 +404,7 @@ public void testArrayFillFunctionWithUpsert3() throws Exception { @Test public void testArrayFillFunctionWithUpsertSelect1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String ddl = "CREATE TABLE source (region_name VARCHAR PRIMARY KEY,doubles DOUBLE[])"; conn.createStatement().execute(ddl); @@ -445,7 +446,7 @@ public void testArrayFillFunctionWithUpsertSelect1() throws Exception { @Test public void testArrayFillFunctionWithUpsertSelect2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String source = generateUniqueName(); String ddl = @@ -496,7 +497,7 @@ public void testArrayFillFunctionWithUpsertSelect2() throws Exception { @Test public void testArrayFillFunctionInWhere1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; @@ -510,7 +511,7 @@ public void testArrayFillFunctionInWhere1() throws Exception { @Test public void testArrayFillFunctionInWhere2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; @@ -524,7 +525,7 @@ public void testArrayFillFunctionInWhere2() throws Exception { @Test public void testArrayFillFunctionInWhere3() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; @@ -538,7 +539,7 @@ public void testArrayFillFunctionInWhere3() throws Exception { @Test public void testArrayFillFunctionInWhere4() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; @@ -552,7 +553,7 @@ public void testArrayFillFunctionInWhere4() throws Exception { @Test public void testArrayFillFunctionInWhere5() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; @@ -566,7 +567,7 @@ public void testArrayFillFunctionInWhere5() throws Exception { @Test public void testArrayFillFunctionInWhere6() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; @@ -580,7 +581,7 @@ public void testArrayFillFunctionInWhere6() throws Exception { @Test public void testArrayFillFunctionInWhere7() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java index ddc965a122a..988f6a2b663 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java @@ -17,9 +17,6 @@ */ package org.apache.phoenix.end2end; -import static org.apache.phoenix.util.TestUtil.B_VALUE; -import static org.apache.phoenix.util.TestUtil.ROW1; - import java.sql.Array; import java.sql.Connection; import java.sql.Date; @@ -30,7 +27,10 @@ import java.util.Properties; import org.apache.phoenix.query.BaseTest; - +import org.apache.phoenix.util.PropertiesUtil; +import static org.apache.phoenix.util.TestUtil.ROW1; +import static org.apache.phoenix.util.TestUtil.B_VALUE; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; public abstract class ArrayIT extends ParallelStatsDisabledIT { protected static String createTableWithArray(String url, byte[][] bs, Object object) throws SQLException { @@ -61,7 +61,7 @@ protected static String createTableWithArray(String url, byte[][] bs, Object obj } protected static void initTablesWithArrays(String tableName, String tenantId, Date date, boolean useNull, String url) throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(url, props); try { // Insert all rows at ts diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayPrependFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayPrependFunctionIT.java index a04afe0a378..97d8cd65946 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayPrependFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayPrependFunctionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -25,9 +26,9 @@ import org.apache.phoenix.schema.TypeMismatchException; import org.apache.phoenix.schema.types.PhoenixArray; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class ArrayPrependFunctionIT extends ParallelStatsDisabledIT { @@ -81,7 +82,7 @@ private void initTablesDesc(Connection conn, String tableName, String type, Stri @Test public void testArrayPrependFunctionInteger() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTables(conn, tableName); @@ -99,7 +100,7 @@ public void testArrayPrependFunctionInteger() throws Exception { @Test public void testArrayPrependFunctionVarchar() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTables(conn, tableName); @@ -117,13 +118,13 @@ public void testArrayPrependFunctionVarchar() throws Exception { @Test public void testArrayPrependFunctionNulls1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String[] s = new String[]{null, null, "1", "2"}; String tableName = generateUniqueName(); initTableWithVarArray(conn, tableName, "VARCHAR", s, null); String[] s2 = new String[]{null, null, null, "1", "2"}; PhoenixArray array2 = (PhoenixArray) conn.createArrayOf("VARCHAR", s2); - conn = DriverManager.getConnection(getUrl()); + conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery("SELECT ARRAY_PREPEND(b,a) FROM " + tableName + " WHERE k = 'a'"); assertTrue(rs.next()); @@ -132,13 +133,13 @@ public void testArrayPrependFunctionNulls1() throws Exception { @Test public void testArrayPrependFunctionNulls2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String[] s = new String[]{"1", "2"}; String tableName = generateUniqueName(); initTableWithVarArray(conn, tableName, "VARCHAR", s, null); String[] s2 = new String[]{null, "1", "2"}; PhoenixArray array2 = (PhoenixArray) conn.createArrayOf("VARCHAR", s2); - conn = DriverManager.getConnection(getUrl()); + conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery("SELECT ARRAY_PREPEND(b,a) FROM " + tableName + " WHERE k = 'a'"); assertTrue(rs.next()); @@ -147,13 +148,13 @@ public void testArrayPrependFunctionNulls2() throws Exception { @Test public void testArrayPrependFunctionNulls3() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String[] s = new String[]{"176", null, "212"}; String tableName = generateUniqueName(); initTableWithVarArray(conn, tableName, "VARCHAR", s, null); String[] s2 = new String[]{null, "176", null, "212"}; PhoenixArray array2 = (PhoenixArray) conn.createArrayOf("VARCHAR", s2); - conn = DriverManager.getConnection(getUrl()); + conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery("SELECT ARRAY_PREPEND(b,a) FROM " + tableName + " WHERE k = 'a'"); assertTrue(rs.next()); @@ -162,13 +163,13 @@ public void testArrayPrependFunctionNulls3() throws Exception { @Test public void testArrayPrependFunctionNulls4() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String[] s = new String[]{"176", null, "212"}; String tableName = generateUniqueName(); initTableWithVarArray(conn, tableName, "VARCHAR", s, "'foo'"); String[] s2 = new String[]{"foo", "176", null, "212"}; PhoenixArray array2 = (PhoenixArray) conn.createArrayOf("VARCHAR", s2); - conn = DriverManager.getConnection(getUrl()); + conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery("SELECT ARRAY_PREPEND(b,a) FROM " + tableName + " WHERE k = 'a'"); assertTrue(rs.next()); @@ -177,7 +178,7 @@ public void testArrayPrependFunctionNulls4() throws Exception { @Test public void testArrayPrependFunctionDouble() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTables(conn, tableName); @@ -195,7 +196,7 @@ public void testArrayPrependFunctionDouble() throws Exception { @Test public void testArrayPrependFunctionDouble2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTables(conn, tableName); @@ -213,7 +214,7 @@ public void testArrayPrependFunctionDouble2() throws Exception { @Test public void testArrayPrependFunctionBigint() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTables(conn, tableName); ResultSet rs; @@ -230,7 +231,7 @@ public void testArrayPrependFunctionBigint() throws Exception { @Test public void testArrayPrependFunctionChar() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTables(conn, tableName); ResultSet rs; @@ -247,7 +248,7 @@ public void testArrayPrependFunctionChar() throws Exception { @Test(expected = TypeMismatchException.class) public void testArrayPrependFunctionIntToCharArray() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTables(conn, tableName); @@ -257,7 +258,7 @@ public void testArrayPrependFunctionIntToCharArray() throws Exception { @Test(expected = TypeMismatchException.class) public void testArrayPrependFunctionVarcharToIntegerArray() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTables(conn, tableName); @@ -268,7 +269,7 @@ public void testArrayPrependFunctionVarcharToIntegerArray() throws Exception { @Test(expected = SQLException.class) public void testArrayPrependFunctionChar2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTables(conn, tableName); ResultSet rs; @@ -279,7 +280,7 @@ public void testArrayPrependFunctionChar2() throws Exception { @Test public void testArrayPrependFunctionIntegerToDoubleArray() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTables(conn, tableName); @@ -297,7 +298,7 @@ public void testArrayPrependFunctionIntegerToDoubleArray() throws Exception { @Test public void testArrayPrependFunctionWithNestedFunctions1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTables(conn, tableName); @@ -315,7 +316,7 @@ public void testArrayPrependFunctionWithNestedFunctions1() throws Exception { @Test public void testArrayPrependFunctionWithNestedFunctions2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTables(conn, tableName); @@ -333,7 +334,7 @@ public void testArrayPrependFunctionWithNestedFunctions2() throws Exception { @Test public void testArrayPrependFunctionWithNestedFunctions3() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTables(conn, tableName); @@ -351,7 +352,7 @@ public void testArrayPrependFunctionWithNestedFunctions3() throws Exception { @Test public void testArrayPrependFunctionWithUpsert1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + " (region_name VARCHAR PRIMARY KEY,varchars VARCHAR[])"; conn.createStatement().execute(ddl); @@ -374,7 +375,7 @@ public void testArrayPrependFunctionWithUpsert1() throws Exception { @Test public void testArrayPrependFunctionWithUpsert2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + " (region_name VARCHAR PRIMARY KEY,integers INTEGER[])"; @@ -398,7 +399,7 @@ public void testArrayPrependFunctionWithUpsert2() throws Exception { @Test public void testArrayPrependFunctionWithUpsert3() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + "(region_name VARCHAR PRIMARY KEY,doubles DOUBLE[])"; conn.createStatement().execute(ddl); @@ -421,7 +422,7 @@ public void testArrayPrependFunctionWithUpsert3() throws Exception { @Test public void testArrayPrependFunctionWithUpsertSelect1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String baseTable = generateUniqueName(); String source = baseTable + "_SOURCE"; String target = baseTable + "_TARGET"; @@ -461,7 +462,7 @@ public void testArrayPrependFunctionWithUpsertSelect1() throws Exception { @Test public void testArrayPrependFunctionWithUpsertSelect2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String baseTable = generateUniqueName(); String source = baseTable + "_SOURCE"; String target = baseTable + "_TARGET"; @@ -501,7 +502,7 @@ public void testArrayPrependFunctionWithUpsertSelect2() throws Exception { @Test public void testArrayPrependFunctionInWhere1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTables(conn, tableName); @@ -515,7 +516,7 @@ public void testArrayPrependFunctionInWhere1() throws Exception { @Test public void testArrayPrependFunctionInWhere2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTables(conn, tableName); @@ -529,7 +530,7 @@ public void testArrayPrependFunctionInWhere2() throws Exception { @Test public void testArrayPrependFunctionInWhere3() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTables(conn, tableName); @@ -543,7 +544,7 @@ public void testArrayPrependFunctionInWhere3() throws Exception { @Test public void testArrayPrependFunctionInWhere4() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTables(conn, tableName); @@ -557,7 +558,7 @@ public void testArrayPrependFunctionInWhere4() throws Exception { @Test public void testArrayPrependFunctionInWhere5() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTables(conn, tableName); @@ -571,7 +572,7 @@ public void testArrayPrependFunctionInWhere5() throws Exception { @Test public void testArrayPrependFunctionInWhere6() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTables(conn, tableName); @@ -585,7 +586,7 @@ public void testArrayPrependFunctionInWhere6() throws Exception { @Test public void testArrayPrependFunctionInWhere7() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTables(conn, tableName); @@ -599,7 +600,7 @@ public void testArrayPrependFunctionInWhere7() throws Exception { @Test(expected = SQLException.class) public void testArrayPrependFunctionCharLimitCheck() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTables(conn, tableName); @@ -617,7 +618,7 @@ public void testArrayPrependFunctionCharLimitCheck() throws Exception { @Test public void testArrayPrependFunctionIntegerDesc() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTablesDesc(conn, tableName, "INTEGER", "23"); @@ -636,7 +637,7 @@ public void testArrayPrependFunctionIntegerDesc() throws Exception { @Test public void testArrayPrependFunctionVarcharDesc() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTablesDesc(conn, tableName, "VARCHAR", "'e'"); @@ -654,7 +655,7 @@ public void testArrayPrependFunctionVarcharDesc() throws Exception { @Test public void testArrayPrependFunctionBigIntDesc() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTablesDesc(conn, tableName, "BIGINT", "1112"); ResultSet rs; @@ -671,7 +672,7 @@ public void testArrayPrependFunctionBigIntDesc() throws Exception { @Test public void testArrayPrependFunctionBooleanDesc() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTablesDesc(conn, tableName, "BOOLEAN", "false"); ResultSet rs; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayRemoveFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayRemoveFunctionIT.java index f8015c56085..a69d57eaa9f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayRemoveFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayRemoveFunctionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +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.assertNull; @@ -28,10 +29,10 @@ import java.sql.ResultSet; import org.apache.phoenix.schema.TypeMismatchException; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class ArrayRemoveFunctionIT extends ParallelStatsDisabledIT { @@ -40,7 +41,7 @@ public class ArrayRemoveFunctionIT extends ParallelStatsDisabledIT { @Before public void setup() throws Exception { - conn = DriverManager.getConnection(getUrl()); + conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); tableName = initTables(conn); } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayToStringFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayToStringFunctionIT.java index f5524acb5cb..1aab58cbc48 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayToStringFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayToStringFunctionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +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; @@ -26,10 +27,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class ArrayToStringFunctionIT extends ParallelStatsDisabledIT { private String tableName; @@ -37,7 +38,7 @@ public class ArrayToStringFunctionIT extends ParallelStatsDisabledIT { @Before public void initTables() throws Exception { - conn = DriverManager.getConnection(getUrl()); + conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + " (region_name VARCHAR PRIMARY KEY,varchars VARCHAR[],integers INTEGER[],doubles DOUBLE[],bigints BIGINT[],chars CHAR(15)[],double1 DOUBLE,varchar1 VARCHAR,nullcheck INTEGER,chars2 CHAR(15)[])"; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArraysWithNullsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArraysWithNullsIT.java index 22743b42b58..aaa9018d455 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArraysWithNullsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArraysWithNullsIT.java @@ -18,21 +18,20 @@ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import java.sql.*; -import org.apache.phoenix.schema.types.PTimestamp; -import org.apache.phoenix.schema.types.PhoenixArray; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class ArraysWithNullsIT extends ParallelStatsDisabledIT { @Test public void testArrayUpsertIntWithNulls() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String t1 = generateUniqueName(); conn.createStatement().execute( "CREATE TABLE " + t1 + " ( k VARCHAR PRIMARY KEY, a INTEGER[])"); @@ -55,7 +54,7 @@ public void testArrayUpsertIntWithNulls() throws Exception { @Test public void testArrayUpsertVarcharWithNulls() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String t2 = generateUniqueName(); conn.createStatement().execute( "CREATE TABLE " + t2 + " ( k VARCHAR PRIMARY KEY, a VARCHAR[])"); @@ -76,7 +75,7 @@ public void testArrayUpsertVarcharWithNulls() throws Exception { @Test public void testArrayUpsertBigIntWithNulls() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String t3 = generateUniqueName(); conn.createStatement().execute( "CREATE TABLE " + t3 + " ( k VARCHAR PRIMARY KEY, a BIGINT[])"); @@ -97,7 +96,7 @@ public void testArrayUpsertBigIntWithNulls() throws Exception { @Test public void testArrayUpsertFloatWithNulls() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String t4 = generateUniqueName(); conn.createStatement().execute( "CREATE TABLE " + t4 + " ( k VARCHAR PRIMARY KEY, a FLOAT[])"); @@ -118,7 +117,7 @@ public void testArrayUpsertFloatWithNulls() throws Exception { @Test public void testArrayUpsertSmallIntWithNulls() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String t5 = generateUniqueName(); conn.createStatement().execute( "CREATE TABLE " + t5 + " ( k VARCHAR PRIMARY KEY, a SMALLINT[])"); @@ -139,7 +138,7 @@ public void testArrayUpsertSmallIntWithNulls() throws Exception { @Test public void testArrayUpsertTinyIntWithNulls() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String t6 = generateUniqueName(); conn.createStatement().execute( "CREATE TABLE " + t6 + " ( k VARCHAR PRIMARY KEY, a TINYINT[])"); @@ -160,7 +159,7 @@ public void testArrayUpsertTinyIntWithNulls() throws Exception { @Test public void testArrayUpsertBooleanWithNulls() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String t7 = generateUniqueName(); conn.createStatement().execute( "CREATE TABLE " + t7 + " ( k VARCHAR PRIMARY KEY, a BOOLEAN[])"); @@ -181,7 +180,7 @@ public void testArrayUpsertBooleanWithNulls() throws Exception { @Test public void testArrayUpsertDoubleWithNulls() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String t8 = generateUniqueName(); conn.createStatement().execute( "CREATE TABLE " + t8 + " ( k VARCHAR PRIMARY KEY, a DOUBLE[])"); @@ -202,7 +201,7 @@ public void testArrayUpsertDoubleWithNulls() throws Exception { @Test public void testArrayUpsertDateWithNulls1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String t9 = generateUniqueName(); conn.createStatement().execute("CREATE TABLE " + t9 + " ( k VARCHAR PRIMARY KEY, a DATE[])"); PreparedStatement stmt = conn.prepareStatement("UPSERT INTO " + t9 @@ -220,7 +219,7 @@ public void testArrayUpsertDateWithNulls1() throws Exception { @Test public void testArrayUpsertDateWithNulls2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String t10 = generateUniqueName(); conn.createStatement().execute( "CREATE TABLE " + t10 + " ( k VARCHAR PRIMARY KEY, a DATE[])"); @@ -240,7 +239,7 @@ public void testArrayUpsertDateWithNulls2() throws Exception { @Test public void testArrayUpsertTimeWithNulls1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String t11 = generateUniqueName(); conn.createStatement().execute( "CREATE TABLE " + t11 + " ( k VARCHAR PRIMARY KEY, a TIME[])"); @@ -260,7 +259,7 @@ public void testArrayUpsertTimeWithNulls1() throws Exception { @Test public void testArrayUpsertTimeWithNulls2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String t12 = generateUniqueName(); conn.createStatement().execute( "CREATE TABLE " + t12 + " ( k VARCHAR PRIMARY KEY, a TIME[])"); @@ -280,7 +279,7 @@ public void testArrayUpsertTimeWithNulls2() throws Exception { @Test public void testArrayUpsertTimeStampWithNulls1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String t13 = generateUniqueName(); conn.createStatement().execute( "CREATE TABLE " + t13 + " ( k VARCHAR PRIMARY KEY, a TIMESTAMP[])"); @@ -299,7 +298,7 @@ public void testArrayUpsertTimeStampWithNulls1() throws Exception { @Test public void testArrayUpsertTimeStampWithNulls2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String t14 = generateUniqueName(); conn.createStatement().execute( "CREATE TABLE " + t14 + " ( k VARCHAR PRIMARY KEY, a TIMESTAMP[])"); @@ -318,7 +317,7 @@ public void testArrayUpsertTimeStampWithNulls2() throws Exception { @Test public void testArrayUpsertCharWithNulls1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String t15 = generateUniqueName(); conn.createStatement().execute( "CREATE TABLE " + t15 + " ( k VARCHAR PRIMARY KEY, a CHAR(15)[])"); @@ -337,7 +336,7 @@ public void testArrayUpsertCharWithNulls1() throws Exception { @Test public void testArrayUpsertCharWithNulls2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String t16 = generateUniqueName(); conn.createStatement().execute( "CREATE TABLE " + t16 + " ( k VARCHAR PRIMARY KEY, a CHAR(15)[])"); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AuditLoggingIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AuditLoggingIT.java index 14e24f09dd4..02b60c1d24c 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AuditLoggingIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AuditLoggingIT.java @@ -30,7 +30,6 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertEquals; - @Category(ParallelStatsDisabledTest.class) public class AuditLoggingIT extends ParallelStatsDisabledIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AutoCommitIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AutoCommitIT.java index a9228b736ea..0cc8220833b 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AutoCommitIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AutoCommitIT.java @@ -32,7 +32,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class AutoCommitIT extends ParallelStatsDisabledIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AutoPartitionViewsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AutoPartitionViewsIT.java index 590ec7636f1..a54c00b1a59 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AutoPartitionViewsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AutoPartitionViewsIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -41,12 +42,12 @@ import org.apache.phoenix.schema.TableAlreadyExistsException; import org.apache.phoenix.schema.types.PInteger; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; - @Category(ParallelStatsDisabledTest.class) @RunWith(Parameterized.class) public class AutoPartitionViewsIT extends ParallelStatsDisabledIT { @@ -74,13 +75,13 @@ public AutoPartitionViewsIT(boolean salted, boolean isMultiTenant) { @Test public void testValidateAttributes() throws SQLException { - try (Connection conn = DriverManager.getConnection(getUrl()); - Connection viewConn1 = - isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1) - : DriverManager.getConnection(getUrl()); - Connection viewConn2 = + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Connection viewConn1 = isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1) - : DriverManager.getConnection(getUrl())) { + : DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Connection viewConn2 = + isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES)) + : DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES));) { String tableName = generateUniqueName(); String autoSeqName = generateUniqueName(); @@ -229,13 +230,13 @@ public void testValidateAttributes() throws SQLException { @Test public void testViewCreationFailure() throws SQLException { - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection viewConn1 = - isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1) - : DriverManager.getConnection(getUrl()); + isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES)) + : DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection viewConn2 = - isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL2) - : DriverManager.getConnection(getUrl())) { + isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL2, PropertiesUtil.deepCopy(TEST_PROPERTIES)) + : DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tableName = generateUniqueName(); String autoSeqName = generateUniqueName(); @@ -313,10 +314,10 @@ public void testViewCreationFailure() throws SQLException { @Test public void testAddDropColumns() throws SQLException { - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection viewConn1 = - isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1) - : DriverManager.getConnection(getUrl())) { + isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES)) + : DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tableName = generateUniqueName(); String autoSeqName = generateUniqueName(); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BackwardCompatibilityForSplittableSyscatIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BackwardCompatibilityForSplittableSyscatIT.java index e7ee8f6bcfa..bec931d99f8 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BackwardCompatibilityForSplittableSyscatIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BackwardCompatibilityForSplittableSyscatIT.java @@ -42,7 +42,6 @@ /** * This class is meant for specifically testing syscat with all compatible client versions. */ - @RunWith(Parameterized.class) @Category(NeedsOwnMiniClusterTest.class) public class BackwardCompatibilityForSplittableSyscatIT extends SplitSystemCatalogIT { @@ -63,9 +62,9 @@ public BackwardCompatibilityForSplittableSyscatIT(MavenCoordinates compatibleCli public synchronized void setup() throws Exception { Map serverProps = Maps.newHashMapWithExpectedSize(1); doSetup(serverProps); - zkQuorum = "localhost:" + getZKClientPort(config); + zkQuorum = "localhost:" + getZKClientPort(getConfiguration()); url = PhoenixRuntime.JDBC_PROTOCOL + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum; - checkForPreConditions(compatibleClientVersion, config); + checkForPreConditions(compatibleClientVersion, getConfiguration()); } @Test diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BackwardCompatibilityIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BackwardCompatibilityIT.java index 6348497119a..e65ae7fc861 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BackwardCompatibilityIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BackwardCompatibilityIT.java @@ -44,7 +44,12 @@ import static org.apache.phoenix.end2end.BackwardCompatibilityTestUtil.executeQueryWithClientVersion; import static org.apache.phoenix.end2end.BackwardCompatibilityTestUtil.UpgradeProps.NONE; import static org.apache.phoenix.end2end.BackwardCompatibilityTestUtil.UpgradeProps.SET_MAX_LOOK_BACK_AGE; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +import static org.apache.phoenix.query.BaseTest.getConfiguration; +import static org.apache.phoenix.query.BaseTest.getUtility; import static org.apache.phoenix.query.BaseTest.setUpConfigForMiniCluster; +import static org.apache.phoenix.query.BaseTest.setUpTestClusterForHA; +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.assertNull; @@ -53,9 +58,11 @@ import java.sql.Connection; import java.sql.DriverManager; import java.util.Collection; +import java.util.Map; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HBaseTestingUtility; +import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.TableDescriptor; @@ -64,11 +71,15 @@ import org.apache.phoenix.end2end.BackwardCompatibilityTestUtil.MavenCoordinates; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; import org.apache.phoenix.jdbc.PhoenixDriver; +import org.apache.phoenix.jdbc.ZKConnectionInfo; import org.apache.phoenix.query.BaseTest; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.query.QueryServicesOptions; import org.apache.phoenix.schema.SystemTaskSplitPolicy; +import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; +import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.ServerUtil.ConnectionFactory; import org.junit.After; import org.junit.Assume; @@ -86,7 +97,6 @@ * against the current server version. It runs SQL queries with given * client versions and compares the output against gold files */ - @RunWith(Parameterized.class) @Category(NeedsOwnMiniClusterTest.class) public class BackwardCompatibilityIT { @@ -113,18 +123,30 @@ public static synchronized Collection data() throws Exception @Before public synchronized void doSetup() throws Exception { tmpDir = System.getProperty("java.io.tmpdir"); - conf = HBaseConfiguration.create(); - conf.set(QueryServices.TASK_HANDLING_INTERVAL_MS_ATTRIB, - Long.toString(Long.MAX_VALUE)); - conf.set(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, - Long.toString(Long.MAX_VALUE)); - hbaseTestUtil = new HBaseTestingUtility(conf); - setUpConfigForMiniCluster(conf); - conf.set(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS); - hbaseTestUtil.startMiniCluster(); - zkQuorum = "localhost:" + hbaseTestUtil.getZkCluster().getClientPort(); - url = PhoenixRuntime.JDBC_PROTOCOL + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum; - DriverManager.registerDriver(PhoenixDriver.INSTANCE); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + Map props = Maps.newHashMapWithExpectedSize(1); + props.put(HConstants.ZOOKEEPER_ZNODE_PARENT, "/hbase-test"); + props.put(HConstants.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY, ZKConnectionInfo.ZK_REGISTRY_NAME); + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + conf = getConfiguration(); + hbaseTestUtil = getUtility(); + zkQuorum = "localhost:" + hbaseTestUtil.getZkCluster().getClientPort(); + url = PhoenixRuntime.JDBC_PROTOCOL + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum; + + } else { + conf = HBaseConfiguration.create(); + conf.set(QueryServices.TASK_HANDLING_INTERVAL_MS_ATTRIB, + Long.toString(Long.MAX_VALUE)); + conf.set(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, + Long.toString(Long.MAX_VALUE)); + hbaseTestUtil = new HBaseTestingUtility(conf); + setUpConfigForMiniCluster(conf); + conf.set(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS); + hbaseTestUtil.startMiniCluster(); + zkQuorum = "localhost:" + hbaseTestUtil.getZkCluster().getClientPort(); + url = PhoenixRuntime.JDBC_PROTOCOL + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum; + DriverManager.registerDriver(PhoenixDriver.INSTANCE); + } checkForPreConditions(compatibleClientVersion, conf); } @@ -188,7 +210,7 @@ public void testCreateDivergedViewWithOldClientReadFromOldClientAfterUpgrade() throws Exception { // Create a base table, view and make it diverge from an old client executeQueryWithClientVersion(compatibleClientVersion, CREATE_DIVERGED_VIEW, zkQuorum); - try (Connection conn = DriverManager.getConnection(url)) { + try (Connection conn = DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { // Just connect with a new client to cause a metadata upgrade } // Query with an old client again diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseAggregateIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseAggregateIT.java index 841f2fc4b0b..1570d29edba 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseAggregateIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseAggregateIT.java @@ -48,7 +48,6 @@ import org.apache.phoenix.util.TestUtil; import org.junit.Test; - public abstract class BaseAggregateIT extends ParallelStatsDisabledIT { private static void initData(Connection conn, String tableName) throws SQLException { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseAggregateWithRegionMoves2IT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseAggregateWithRegionMoves2IT.java index 2e6c15a6515..5b0a79560a4 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseAggregateWithRegionMoves2IT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseAggregateWithRegionMoves2IT.java @@ -48,7 +48,6 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; - @Category(NeedsOwnMiniClusterTest.class) public class BaseAggregateWithRegionMoves2IT extends ParallelStatsDisabledWithRegionMovesIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseAggregateWithRegionMoves3IT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseAggregateWithRegionMoves3IT.java index 7e8caf90c07..f94ebf333df 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseAggregateWithRegionMoves3IT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseAggregateWithRegionMoves3IT.java @@ -36,6 +36,8 @@ import java.util.HashMap; import java.util.Map; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; + @Category(NeedsOwnMiniClusterTest.class) public class BaseAggregateWithRegionMoves3IT extends BaseAggregateWithRegionMoves2IT { @@ -113,7 +115,11 @@ public static synchronized void doSetup() throws Exception { TestScanningResultPostDummyResultCaller.class.getName()); props.put(QueryServices.PHOENIX_POST_VALID_PROCESS, TestScanningResultPostValidResultCaller.class.getName()); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @AfterClass diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseAggregateWithRegionMoves4IT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseAggregateWithRegionMoves4IT.java index cab93de4e25..37daf81d99c 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseAggregateWithRegionMoves4IT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseAggregateWithRegionMoves4IT.java @@ -40,8 +40,8 @@ import java.util.Map; import java.util.Properties; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; - @Category(NeedsOwnMiniClusterTest.class) public class BaseAggregateWithRegionMoves4IT extends BaseAggregateWithRegionMoves2IT { @@ -94,7 +94,11 @@ public static synchronized void doSetup() throws Exception { props.put(HConstants.HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY, String.valueOf(1)); props.put(QueryServices.PHOENIX_POST_VALID_PROCESS, TestScanningResultPostValidResultCaller.class.getName()); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @AfterClass diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseAggregateWithRegionMovesIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseAggregateWithRegionMovesIT.java index a0dca2651e4..6f9b32c19d9 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseAggregateWithRegionMovesIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseAggregateWithRegionMovesIT.java @@ -48,7 +48,6 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; - public abstract class BaseAggregateWithRegionMovesIT extends ParallelStatsDisabledWithRegionMovesIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseMutationBatchFailedStateMetricIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseMutationBatchFailedStateMetricIT.java index 63940901879..49c5206ba97 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseMutationBatchFailedStateMetricIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseMutationBatchFailedStateMetricIT.java @@ -29,11 +29,14 @@ import org.apache.phoenix.hbase.index.Indexer; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; + +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import org.junit.BeforeClass; import org.junit.runners.Parameterized; - public class BaseMutationBatchFailedStateMetricIT extends ParallelStatsDisabledIT { String create_table = "CREATE TABLE IF NOT EXISTS %s(ID VARCHAR NOT NULL PRIMARY KEY, VAL1 INTEGER, VAL2 INTEGER)"; @@ -66,8 +69,13 @@ public static synchronized void doSetup() throws Exception { Map clientProps = Maps.newHashMapWithExpectedSize(2); clientProps.put(QueryServices.COLLECT_REQUEST_LEVEL_METRICS, String.valueOf(true)); clientProps.put(QueryServices.TRANSACTIONS_ENABLED, "true"); - setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), - new ReadOnlyProps(clientProps.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(serverProps.entrySet().iterator()), + new ReadOnlyProps(clientProps.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), + new ReadOnlyProps(clientProps.entrySet().iterator())); + } } @@ -78,7 +86,7 @@ public static synchronized Collection data() { private void populateTables() { final int NROWS = 5; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { try (PreparedStatement dataPreparedStatement = conn.prepareStatement(String.format(upsertStatement, deleteTableName))) { for (int i = 1; i <= NROWS; i++) { @@ -94,7 +102,7 @@ private void populateTables() { } } private void createTables() { - try (Connection con = DriverManager.getConnection(getUrl())) { + try (Connection con = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { Statement stmt = con.createStatement(); stmt.execute(String.format(create_table, deleteTableName)); stmt.execute(String.format(create_index, deleteTableName)); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOrderByIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOrderByIT.java index dcd7463887c..5ef326422e4 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOrderByIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOrderByIT.java @@ -53,7 +53,6 @@ import org.junit.Before; import org.junit.Test; - public abstract class BaseOrderByIT extends ParallelStatsDisabledIT { Properties props; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOrderByWithRegionMovesIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOrderByWithRegionMovesIT.java index 526d4f608d4..1b33ce636c7 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOrderByWithRegionMovesIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseOrderByWithRegionMovesIT.java @@ -53,7 +53,6 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; - public abstract class BaseOrderByWithRegionMovesIT extends ParallelStatsDisabledWithRegionMovesIT { @Before diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BasePermissionsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BasePermissionsIT.java index 53e8cb68947..780a34af8b9 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BasePermissionsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BasePermissionsIT.java @@ -353,7 +353,7 @@ public Connection getConnection(String tenantId) throws SQLException { return DriverManager.getConnection(getUrl(), getClientProperties(tenantId)); } - protected static String getUrl() { + public static String getUrl() { return "jdbc:phoenix:localhost:" + testUtil.getZkCluster().getClientPort() + ":/hbase"; } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseRowKeyMatcherTestIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseRowKeyMatcherTestIT.java index 8a8c467b602..3f83e2d5e06 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseRowKeyMatcherTestIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseRowKeyMatcherTestIT.java @@ -43,6 +43,7 @@ import org.apache.phoenix.expression.Expression; import org.apache.phoenix.expression.RowKeyColumnExpression; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixPreparedStatement; import org.apache.phoenix.parse.ParseNode; import org.apache.phoenix.parse.SQLParser; @@ -103,10 +104,10 @@ import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_LINK_HBASE_TABLE_NAME; import static org.apache.phoenix.util.ByteUtil.EMPTY_BYTE_ARRAY; import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; - public abstract class BaseRowKeyMatcherTestIT extends ParallelStatsDisabledIT { private static final Logger LOGGER = LoggerFactory.getLogger(BaseRowKeyMatcherTestIT.class); @@ -247,7 +248,7 @@ private void createBaseTable(String tableName, boolean isMultiTenant, PDataType throws SQLException { String baseTableName = String.format(BASE_TABLE_NAME_FMT, tableName); - try (Connection globalConnection = DriverManager.getConnection(getUrl())) { + try (Connection globalConnection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { try (Statement cstmt = globalConnection.createStatement()) { String CO_BASE_TBL_TEMPLATE = @@ -276,8 +277,8 @@ private Pair createGlobalView(String tableName, int partition, String baseTableName = String.format(BASE_TABLE_NAME_FMT, tableName); String partitionName = String.format(PARTITION_FMT, partition); String globalViewName = String.format(GLOBAL_VIEW_NAME_FMT, partitionName); - try (PhoenixConnection globalConnection = DriverManager.getConnection(getUrl()) - .unwrap(PhoenixConnection.class)) { + try (PhoenixMonitoredConnection globalConnection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)) + .unwrap(PhoenixMonitoredConnection.class)) { try (Statement cstmt = globalConnection.createStatement()) { String VIEW_TEMPLATE = @@ -304,7 +305,7 @@ private Pair createGlobalView(String tableName, int partition, cstmt.execute(globalViewIndexSQL); } - return getRowKeyMatchersFromView(globalConnection.unwrap(PhoenixConnection.class), + return getRowKeyMatchersFromView(globalConnection.unwrap(PhoenixMonitoredConnection.class), globalViewName); } } @@ -331,7 +332,7 @@ private Pair createTenantView(boolean extendPK, int partition, String.format(TENANT_URL_FMT, getUrl(), TENANT_ID_ATTRIB, tenantId); String tenantViewName = String.format(TENANT_VIEW_NAME_FMT, partitionName, tenantViewNum); String tenantViewOptions = ""; - try (Connection tenantConnection = DriverManager.getConnection(tenantConnectionUrl)) { + try (Connection tenantConnection = DriverManager.getConnection(tenantConnectionUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { tenantConnection.setAutoCommit(true); try (Statement cstmt = tenantConnection.createStatement()) { String @@ -351,7 +352,7 @@ private Pair createTenantView(boolean extendPK, int partition, LOGGER.info("Created tenant view ((WO_PK)) {}", viewWithoutPKSQL); cstmt.execute(viewWithoutPKSQL); } - return getRowKeyMatchersFromView(tenantConnection.unwrap(PhoenixConnection.class), + return getRowKeyMatchersFromView(tenantConnection.unwrap(PhoenixMonitoredConnection.class), tenantViewName); } } @@ -384,8 +385,8 @@ private void upsertTenantViewRows(boolean isMultiTenant, boolean extendPK, int p tenantConnectionUrl = String.format(TENANT_URL_FMT, getUrl(), TENANT_ID_ATTRIB, tenantId); String tenantViewName = String.format(TENANT_VIEW_NAME_FMT, partitionName, tenantViewNum); - try (PhoenixConnection tenantConnection = DriverManager.getConnection(tenantConnectionUrl) - .unwrap(PhoenixConnection.class)) { + try (PhoenixMonitoredConnection tenantConnection = DriverManager.getConnection(tenantConnectionUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES)) + .unwrap(PhoenixMonitoredConnection.class)) { tenantConnection.setAutoCommit(true); String TENANT_VIEW_WITH_PK = @@ -489,7 +490,7 @@ private void upsertTenantViewRows(boolean isMultiTenant, boolean extendPK, int p } // Helper to get rowKeyMatcher from Metadata. - private Pair getRowKeyMatchersFromView(PhoenixConnection connection, + private Pair getRowKeyMatchersFromView(PhoenixMonitoredConnection connection, String viewName) throws SQLException { PName tenantId = connection.getTenantId(); @@ -508,7 +509,7 @@ byte[] getRowKeyMatcherFromSyscatIndex(String tenantId, String schemaName, "SELECT ROW_KEY_MATCHER FROM SYSTEM.CATALOG " + "WHERE %s AND TABLE_SCHEM <> 'SYSTEM' AND TABLE_NAME = '%s' AND ROW_KEY_MATCHER IS NOT NULL"; final String SYS_CATALOG_IDX_ROW_KEY_MATCHER_HEADER_SQL = "SELECT \"0:ROW_KEY_MATCHER\" FROM SYSTEM.SYS_ROW_KEY_MATCHER_IDX " + "WHERE %s AND \":TABLE_SCHEM\" = '%s' AND \":TABLE_NAME\" = '%s'"; - try (Connection connection = DriverManager.getConnection(getUrl())) { + try (Connection connection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { Statement stmt = connection.createStatement(); String tenantClause = useIndexTable ? @@ -536,7 +537,7 @@ byte[] getRowKeyMatcherFromSyscatIndex(String tenantId, String schemaName, } // Helper to get rowKeyMatcher from Metadata. - private Pair getRowKeyMatchersFromView(PhoenixConnection connection, + private Pair getRowKeyMatchersFromView(PhoenixMonitoredConnection connection, PTable view) throws SQLException { return getRowKeyMatchersFromView(connection, view.getName().getString()); } @@ -620,11 +621,11 @@ private byte[] assertRowKeyMatcherForView(PhoenixConnection connection, PTable v private Map assertRowKeyMatchersForTable(String url, String parentSchemaName, String parentTableName) { Map viewToRowKeyMap = Maps.newHashMap(); - Properties tenantProps = PropertiesUtil.deepCopy(new Properties()); - try (Connection globalConnection = DriverManager.getConnection(url)) { + Properties tenantProps = PropertiesUtil.deepCopy(PropertiesUtil.deepCopy(TEST_PROPERTIES)); + try (Connection globalConnection = DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { ConnectionQueryServices cqs = - globalConnection.unwrap(PhoenixConnection.class).getQueryServices(); + globalConnection.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); try (Table childLinkTable = cqs.getTable( SchemaUtil.getPhysicalName(SYSTEM_LINK_HBASE_TABLE_NAME.toBytes(), cqs.getProps()).getName())) { @@ -649,7 +650,7 @@ private Map assertRowKeyMatchersForTable(String url, String pare Pair rowKeyInfo = getRowKeyMatchersFromView( - stmtConnection.unwrap(PhoenixConnection.class), view); + stmtConnection.unwrap(PhoenixMonitoredConnection.class), view); assertRowKeyMatcherForView(stmtConnection.unwrap(PhoenixConnection.class), view, rowKeyInfo); viewToRowKeyMap.put(rowKeyInfo.getFirst(), rowKeyInfo.getSecond()); @@ -727,7 +728,7 @@ private String getWhereClause(String[] pkNames, PDataType[] testPKTypes) { } // Asserts that the row matched by the rowId and tenantId matches the prefix - private void assertHBaseRowKeyMatchesPrefix(PhoenixConnection connection, byte[] hbaseTableName, + private void assertHBaseRowKeyMatchesPrefix(PhoenixMonitoredConnection connection, byte[] hbaseTableName, int rowId, byte[] prefix) throws IOException, SQLException { byte[] rowkey = ByteUtil.EMPTY_BYTE_ARRAY; @@ -759,7 +760,7 @@ private void assertHBaseRowKeyMatchesPrefix(PhoenixConnection connection, byte[] } // Asserts that the row matching the tenantId and rowId matches with the viewIndexId - private void assertIndexTableRowKeyMatchesPrefix(PhoenixConnection connection, PTable viewIndex, + private void assertIndexTableRowKeyMatchesPrefix(PhoenixMonitoredConnection connection, PTable viewIndex, byte[] hbaseIndexTableName, int rowId) throws IOException, SQLException { byte[] rowkey = ByteUtil.EMPTY_BYTE_ARRAY; @@ -1118,8 +1119,8 @@ private String createViewHierarchy(PDataType tenantIdType, List tes String.format(TENANT_URL_FMT, getUrl(), TENANT_ID_ATTRIB, tenantId); String tenantViewName = String.format(TENANT_VIEW_NAME_FMT, partitionName, 1); String tenantViewKey = String.format("%s.%s", tenantId, tenantViewName); - try (PhoenixConnection tenantConnection = DriverManager.getConnection( - tenantConnectionUrl).unwrap(PhoenixConnection.class)) { + try (PhoenixMonitoredConnection tenantConnection = DriverManager.getConnection( + tenantConnectionUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixMonitoredConnection.class)) { assertHBaseRowKeyMatchesPrefix(tenantConnection, baseTableName.getBytes(StandardCharsets.UTF_8), rowId, actualViewToRowKeyMap.get(tenantViewKey)); 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 5e9208b59cf..1c625cbdc09 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 @@ -24,7 +24,6 @@ import org.apache.phoenix.query.BaseTest; import org.junit.Before; - public abstract class BaseTenantSpecificTablesIT extends ParallelStatsEnabledIT { protected String TENANT_ID; protected String TENANT_TYPE_ID = "abc"; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificViewIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificViewIndexIT.java index a9272ee3e5b..50c3e626649 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificViewIndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseTenantSpecificViewIndexIT.java @@ -18,6 +18,7 @@ package org.apache.phoenix.end2end; import static org.apache.phoenix.thirdparty.com.google.common.collect.Sets.newHashSet; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import java.sql.Connection; @@ -35,10 +36,10 @@ import org.apache.phoenix.jdbc.PhoenixPreparedStatement; import org.apache.phoenix.schema.types.PVarbinary; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.thirdparty.com.google.common.collect.Lists; - public abstract class BaseTenantSpecificViewIndexIT extends SplitSystemCatalogIT { public static final String NON_STRING_TENANT_ID = "1234"; @@ -108,7 +109,7 @@ protected void testUpdatableViewsWithSameNameDifferentTenants(Integer saltBucket } private void createBaseTable(String tableName, Integer saltBuckets, boolean hasStringTenantId) throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tenantIdType = hasStringTenantId ? "VARCHAR" : "BIGINT"; String ddl = "CREATE TABLE " + tableName + " (t_id " + tenantIdType + " NOT NULL,\n" + "k1 INTEGER NOT NULL,\n" + @@ -216,7 +217,7 @@ private void createAndVerifyIndexNonStringTenantId(Connection conn, String viewN } private Connection createTenantConnection(String tenantId) throws SQLException { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); return DriverManager.getConnection(getUrl(), props); } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewIT.java index 112aa6be747..8264dcc6ee8 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewIT.java @@ -19,6 +19,7 @@ import static org.apache.phoenix.util.TestUtil.analyzeTable; import static org.apache.phoenix.util.TestUtil.getAllSplits; +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; @@ -42,17 +43,18 @@ import org.apache.phoenix.compile.ExplainPlan; import org.apache.phoenix.compile.ExplainPlanAttributes; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixPreparedStatement; import org.apache.phoenix.jdbc.PhoenixStatement; import org.apache.phoenix.query.KeyRange; import org.apache.phoenix.util.MetaDataUtil; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ScanUtil; import org.apache.phoenix.util.SchemaUtil; import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; - @Category(ParallelStatsEnabledTest.class) @RunWith(Parameterized.class) public abstract class BaseViewIT extends ParallelStatsEnabledIT { @@ -87,8 +89,8 @@ protected void testUpdatableViewWithIndex(Integer saltBuckets, boolean localInde String tableName = pair.getFirst(); // Confirm that dropping the view also deletes the rows in the index if (saltBuckets == null) { - try (Connection conn = DriverManager.getConnection(getUrl())) { - Table htable = conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(Bytes.toBytes(tableName)); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { + Table htable = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getTable(Bytes.toBytes(tableName)); if(ScanUtil.isLocalIndex(scan)) { ScanUtil.setLocalIndexAttributes(scan, 0, HConstants.EMPTY_BYTE_ARRAY, HConstants.EMPTY_BYTE_ARRAY, scan.getStartRow(), scan.getStopRow()); } @@ -108,7 +110,7 @@ protected void testUpdatableViewWithIndex(Integer saltBuckets, boolean localInde } protected String testUpdatableView(Integer saltBuckets) throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); if (saltBuckets!=null) { if (tableDDLOptions.length()!=0) tableDDLOptions+=","; @@ -167,7 +169,7 @@ protected Pair testUpdatableViewIndex(Integer saltBuckets, String v protected Pair testUpdatableViewIndex(Integer saltBuckets, boolean localIndex, String viewName) throws Exception { ResultSet rs; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String viewIndexName1 = "I_" + generateUniqueName(); String viewIndexPhysicalName = MetaDataUtil.getViewIndexPhysicalName(fullTableName); if (localIndex) { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewTTLIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewTTLIT.java index 9e73366bd69..22a9d0b2ab7 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewTTLIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewTTLIT.java @@ -28,6 +28,7 @@ import static org.apache.phoenix.query.PhoenixTestBuilder.DDLDefaults.TENANT_VIEW_PK_TYPES; import static org.apache.phoenix.schema.LiteralTTLExpression.TTL_EXPRESSION_NOT_DEFINED; import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -69,6 +70,7 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.PhoenixTestBuilder; import org.apache.phoenix.query.PhoenixTestBuilder.BasicDataReader; import org.apache.phoenix.query.PhoenixTestBuilder.BasicDataWriter; @@ -109,6 +111,7 @@ import org.apache.phoenix.util.EnvironmentEdgeManager; import org.apache.phoenix.util.LogUtil; import org.apache.phoenix.util.ManualEnvironmentEdge; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.util.TestUtil; @@ -118,7 +121,6 @@ import org.junit.runners.Parameterized; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - @RunWith(Parameterized.class) public abstract class BaseViewTTLIT extends ParallelStatsDisabledIT { static final Logger LOGGER = LoggerFactory.getLogger(ViewTTLIT.class); @@ -314,14 +316,14 @@ private void clearCache(boolean globalFixNeeded, boolean tenantFixNeeded, List data() { public void testSynchronousDeletesAndUpsertValues() throws Exception { final String tableName = generateUniqueName(); final String indexName = generateUniqueName(); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute("CREATE TABLE " + tableName + "(k1 INTEGER NOT NULL, k2 INTEGER NOT NULL, v1 INTEGER, CONSTRAINT pk PRIMARY KEY (k1,k2)) COLUMN_ENCODED_BYTES = 0"); TestUtil.addCoprocessor(conn, tableName, DelayingRegionObserver.class); @@ -111,12 +117,12 @@ public void testSynchronousDeletesAndUpsertValues() throws Exception { @Override public void run() { try { - Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); for (int i = 0; i < 50; i++) { Thread.sleep(20); synchronized (lock) { - try (PhoenixConnection conn = DriverManager.getConnection(getUrl(), props) - .unwrap(PhoenixConnection.class)) { + try (PhoenixMonitoredConnection conn = DriverManager.getConnection(getUrl(), props) + .unwrap(PhoenixMonitoredConnection.class)) { conn.setAutoCommit(true); conn.createStatement().execute("DELETE FROM " + tableName); } @@ -137,12 +143,12 @@ public void testSynchronousDeletesAndUpsertValues() throws Exception { @Override public void run() { try { - Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); int nRowsToUpsert = 1000; for (int i = 0; i < nRowsToUpsert; i++) { synchronized (lock) { - try (PhoenixConnection conn = DriverManager.getConnection(getUrl(), props) - .unwrap(PhoenixConnection.class)) { + try (PhoenixMonitoredConnection conn = DriverManager.getConnection(getUrl(), props) + .unwrap(PhoenixMonitoredConnection.class)) { conn.createStatement().execute( "UPSERT INTO " + tableName + " VALUES (" + (i % 10) + ", 0, 1)"); @@ -174,7 +180,7 @@ public void testConcurrentDeletesAndUpsertValues() throws Exception { final String tableName = generateUniqueName(); final String indexName = generateUniqueName(); final String singleCellindexName = "SC_" + generateUniqueName(); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute("CREATE TABLE " + tableName + "(k1 INTEGER NOT NULL, k2 INTEGER NOT NULL, v1 INTEGER, CONSTRAINT pk PRIMARY KEY (k1,k2))"); TestUtil.addCoprocessor(conn, tableName, DelayingRegionObserver.class); @@ -188,7 +194,7 @@ public void testConcurrentDeletesAndUpsertValues() throws Exception { @Override public void run() { try { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.setAutoCommit(true); for (int i = 0; i < 50; i++) { Thread.sleep(20); @@ -209,7 +215,7 @@ public void testConcurrentDeletesAndUpsertValues() throws Exception { @Override public void run() { try { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); for (int i = 0; i < 1000; i++) { conn.createStatement().execute( "UPSERT INTO " + tableName + " VALUES (" + (i % 10) + ", 0, 1)"); @@ -244,7 +250,7 @@ public void testConcurrentUpserts() throws Exception { final int nIndexValues = 23; final String tableName = generateUniqueName(); final String indexName = generateUniqueName(); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute("CREATE TABLE " + tableName + "(k1 INTEGER NOT NULL, k2 INTEGER NOT NULL, a.v1 INTEGER, b.v2 INTEGER, c.v3 INTEGER, d.v4 INTEGER," + "CONSTRAINT pk PRIMARY KEY (k1,k2)) COLUMN_ENCODED_BYTES = 0, VERSIONS=1"); @@ -258,7 +264,7 @@ public void testConcurrentUpserts() throws Exception { @Override public void run() { try { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); for (int i = 0; i < 10000; i++) { conn.createStatement().execute( "UPSERT INTO " + tableName + " VALUES (" + (i % nRows) + ", 0, " @@ -296,7 +302,7 @@ public void testConcurrentUpserts() throws Exception { public void testRowLockDuringPreBatchMutateWhenIndexed() throws Exception { final String tableName = LOCK_TEST_TABLE_PREFIX + generateUniqueName(); final String indexName = generateUniqueName(); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute("CREATE TABLE " + tableName + "(k VARCHAR PRIMARY KEY, v INTEGER) COLUMN_ENCODED_BYTES = 0"); @@ -309,7 +315,7 @@ public void testRowLockDuringPreBatchMutateWhenIndexed() throws Exception { @Override public void run() { try { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement() .execute("UPSERT INTO " + tableName + " VALUES ('foo',0)"); conn.createStatement() @@ -328,7 +334,7 @@ public void testRowLockDuringPreBatchMutateWhenIndexed() throws Exception { @Override public void run() { try { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement() .execute("UPSERT INTO " + tableName + " VALUES ('foo',2)"); conn.createStatement() @@ -358,7 +364,7 @@ public void testRowLockDuringPreBatchMutateWhenIndexed() throws Exception { public void testLockUntilMVCCAdvanced() throws Exception { final String tableName = MVCC_LOCK_TEST_TABLE_PREFIX + generateUniqueName(); final String indexName = generateUniqueName(); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute("CREATE TABLE " + tableName + "(k VARCHAR PRIMARY KEY, v INTEGER) COLUMN_ENCODED_BYTES = 0"); conn.createStatement().execute("CREATE "+ (uncovered ? "UNCOVERED " : " ") + "INDEX " + indexName @@ -372,7 +378,7 @@ public void testLockUntilMVCCAdvanced() throws Exception { @Override public void run() { try { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement() .execute("UPSERT INTO " + tableName + " VALUES ('foo',1)"); conn.commit(); @@ -389,7 +395,7 @@ public void testLockUntilMVCCAdvanced() throws Exception { @Override public void run() { try { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement() .execute("UPSERT INTO " + tableName + " VALUES ('foo',2)"); conn.commit(); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConcurrentMutationsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConcurrentMutationsIT.java index 8a3dc5e1367..89b57050888 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConcurrentMutationsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConcurrentMutationsIT.java @@ -54,7 +54,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; - @Category(ParallelStatsDisabledTest.class) @RunWith(RunUntilFailure.class) public class ConcurrentMutationsIT extends ParallelStatsDisabledIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConcurrentUpsertsWithoutIndexedColsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConcurrentUpsertsWithoutIndexedColsIT.java index 55a4d3c3f2c..1694153a004 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConcurrentUpsertsWithoutIndexedColsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConcurrentUpsertsWithoutIndexedColsIT.java @@ -23,6 +23,7 @@ import org.apache.phoenix.query.BaseTest; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.thirdparty.com.google.common.collect.ImmutableMap; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.RunUntilFailure; import org.apache.phoenix.util.TestUtil; @@ -44,9 +45,10 @@ import java.util.concurrent.TimeUnit; import static org.apache.phoenix.end2end.IndexToolIT.verifyIndexTable; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertTrue; - @Category(NeedsOwnMiniClusterTest.class) @RunWith(RunUntilFailure.class) public class ConcurrentUpsertsWithoutIndexedColsIT @@ -64,7 +66,11 @@ public class ConcurrentUpsertsWithoutIndexedColsIT @BeforeClass public static synchronized void doSetup() throws Exception { - setUpTestDriver(new ReadOnlyProps(PROPS.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(PROPS.entrySet().iterator()),new ReadOnlyProps(PROPS.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(PROPS.entrySet().iterator())); + } } @Test @@ -74,7 +80,7 @@ public void testConcurrentUpsertsWithoutIndexedColumns() throws Exception { final int nRows = 997; final String tableName = generateUniqueName(); final String indexName = generateUniqueName(); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute("CREATE TABLE " + tableName + "(k1 INTEGER NOT NULL, k2 INTEGER NOT NULL, a.v1 INTEGER, " + "b.v2 INTEGER, c.v3 INTEGER, d.v4 INTEGER," @@ -116,7 +122,7 @@ public TestRunnable(String tableName, int nRows, int batchSize, @Override public void run() { try { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); for (int i = 0; i < 1000; i++) { if (RANDOM.nextInt() % 1000 < 10) { // Do not include the indexed column in upserts diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConfigurableCacheIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConfigurableCacheIT.java index eca73ce50bf..b61901ec056 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConfigurableCacheIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConfigurableCacheIT.java @@ -41,7 +41,7 @@ public class ConfigurableCacheIT extends ParallelStatsEnabledIT { public static synchronized void initTables() throws Exception { table = generateUniqueName(); // Use phoenix test driver for setup - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement() .execute("CREATE TABLE " + table + " (k INTEGER PRIMARY KEY, c1.a bigint, c2.b bigint)" @@ -66,7 +66,7 @@ public static synchronized void initTables() throws Exception { private Connection getCacheFactory(String principal, String cacheFactoryString) throws Exception { - String url = getUrl(); + String url = getActiveUrl(); url = url.replace(";" + PhoenixRuntime.PHOENIX_TEST_DRIVER_URL_PARAM, ""); // As there is a map of connections in the phoenix driver need to differentiate the url to @@ -96,7 +96,7 @@ private Connection getCacheFactory(String principal, String cacheFactoryString) @Test public void testWithDefaults() throws Exception { int initialCount = ITGuidePostsCacheFactory.getCount(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().executeQuery("SELECT * FROM " + table); } assertEquals(initialCount, ITGuidePostsCacheFactory.getCount()); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionIT.java index 1edc4b9843a..2d399c6c2fe 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionIT.java @@ -18,7 +18,11 @@ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +import static org.apache.phoenix.query.BaseTest.getConfiguration; import static org.apache.phoenix.query.BaseTest.setUpConfigForMiniCluster; +import static org.apache.phoenix.query.BaseTest.setUpTestClusterForHA; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assume.assumeTrue; @@ -28,6 +32,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; +import java.util.Map; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseTestingUtility; @@ -35,17 +40,20 @@ import org.apache.hadoop.hbase.util.VersionInfo; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixDriver; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixTestDriver; import org.apache.phoenix.jdbc.RPCConnectionInfo; import org.apache.phoenix.jdbc.ZKConnectionInfo; import org.apache.phoenix.mapreduce.util.ConnectionUtil; import org.apache.phoenix.query.ConfigurationFactory; +import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; import org.apache.phoenix.util.InstanceResolver; +import org.apache.phoenix.util.PropertiesUtil; +import org.apache.phoenix.util.ReadOnlyProps; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(NeedsOwnMiniClusterTest.class) public class ConnectionIT { @@ -56,29 +64,37 @@ public class ConnectionIT { @BeforeClass public static synchronized void setUp() throws Exception { - hbaseTestUtil = new HBaseTestingUtility(); - conf = hbaseTestUtil.getConfiguration(); - setUpConfigForMiniCluster(conf); - conf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/hbase-test"); - conf.set(HConstants.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY, ZKConnectionInfo.ZK_REGISTRY_NAME); - hbaseTestUtil.startMiniCluster(); - Class.forName(PhoenixDriver.class.getName()); - DriverManager.registerDriver(new PhoenixTestDriver()); - InstanceResolver.clearSingletons(); - // Make sure the ConnectionInfo doesn't try to pull a default Configuration - InstanceResolver.getSingleton(ConfigurationFactory.class, new ConfigurationFactory() { - @Override - public Configuration getConfiguration() { - return new Configuration(conf); - } - - @Override - public Configuration getConfiguration(Configuration confToClone) { - Configuration copy = new Configuration(conf); - copy.addResource(confToClone); - return copy; - } - }); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + Map props = Maps.newHashMapWithExpectedSize(1); + props.put(HConstants.ZOOKEEPER_ZNODE_PARENT, "/hbase-test"); + props.put(HConstants.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY, ZKConnectionInfo.ZK_REGISTRY_NAME); + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + conf = getConfiguration(); + } else { + hbaseTestUtil = new HBaseTestingUtility(); + conf = hbaseTestUtil.getConfiguration(); + setUpConfigForMiniCluster(conf); + conf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/hbase-test"); + conf.set(HConstants.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY, ZKConnectionInfo.ZK_REGISTRY_NAME); + hbaseTestUtil.startMiniCluster(); + Class.forName(PhoenixDriver.class.getName()); + DriverManager.registerDriver(new PhoenixTestDriver()); + InstanceResolver.clearSingletons(); + // Make sure the ConnectionInfo doesn't try to pull a default Configuration + InstanceResolver.getSingleton(ConfigurationFactory.class, new ConfigurationFactory() { + @Override + public Configuration getConfiguration() { + return new Configuration(conf); + } + + @Override + public Configuration getConfiguration(Configuration confToClone) { + Configuration copy = new Configuration(conf); + copy.addResource(confToClone); + return copy; + } + }); + } } @AfterClass @@ -88,10 +104,10 @@ public static synchronized void cleanUp() throws Exception { @Test public void testInputAndOutputConnections() throws SQLException { - try (Connection inputConnection = ConnectionUtil.getInputConnection(conf)) { + try (Connection inputConnection = ConnectionUtil.getInputConnection(conf, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { smoke(inputConnection); } - try (Connection outputConnection = ConnectionUtil.getOutputConnection(conf)) { + try (Connection outputConnection = ConnectionUtil.getOutputConnection(conf, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { smoke(outputConnection); } } @@ -112,13 +128,13 @@ private void smoke(Connection conn) throws SQLException { public void testZkConnections() throws SQLException { String zkQuorum = conf.get(HConstants.ZOOKEEPER_QUORUM); String zkPort = conf.get(HConstants.ZOOKEEPER_CLIENT_PORT); - try (PhoenixConnection conn1 = - (PhoenixConnection) DriverManager.getConnection("jdbc:phoenix"); - PhoenixConnection conn2 = - (PhoenixConnection) DriverManager.getConnection("jdbc:phoenix+zk"); - PhoenixConnection conn3 = - (PhoenixConnection) DriverManager - .getConnection("jdbc:phoenix+zk:" + zkQuorum + ":" + zkPort);) { + try (PhoenixMonitoredConnection conn1 = + (PhoenixMonitoredConnection) DriverManager.getConnection("jdbc:phoenix", PropertiesUtil.deepCopy(TEST_PROPERTIES)); + PhoenixMonitoredConnection conn2 = + (PhoenixMonitoredConnection) DriverManager.getConnection("jdbc:phoenix+zk", PropertiesUtil.deepCopy(TEST_PROPERTIES)); + PhoenixMonitoredConnection conn3 = + (PhoenixMonitoredConnection) DriverManager + .getConnection("jdbc:phoenix+zk:" + zkQuorum + ":" + zkPort, PropertiesUtil.deepCopy(TEST_PROPERTIES));) { smoke(conn1); smoke(conn2); smoke(conn3); @@ -132,11 +148,11 @@ public void testMasterConnections() throws SQLException { assumeTrue(VersionInfo.compareVersion(VersionInfo.getVersion(), "2.3.0") >= 0); int masterPortString = conf.getInt(HConstants.MASTER_PORT, HConstants.DEFAULT_MASTER_PORT); String masterHosts = conf.get(HConstants.MASTER_ADDRS_KEY); - try (PhoenixConnection conn1 = - (PhoenixConnection) DriverManager.getConnection("jdbc:phoenix+master"); - PhoenixConnection conn2 = - (PhoenixConnection) DriverManager.getConnection("jdbc:phoenix+master:" - + masterHosts.replaceAll(":", "\\\\:") + ":" + masterPortString);) { + try (PhoenixMonitoredConnection conn1 = + (PhoenixMonitoredConnection) DriverManager.getConnection("jdbc:phoenix+master", PropertiesUtil.deepCopy(TEST_PROPERTIES)); + PhoenixMonitoredConnection conn2 = + (PhoenixMonitoredConnection) DriverManager.getConnection("jdbc:phoenix+master:" + + masterHosts.replaceAll(":", "\\\\:") + ":" + masterPortString, PropertiesUtil.deepCopy(TEST_PROPERTIES));) { smoke(conn1); smoke(conn2); assertEquals(conn1.getQueryServices(), conn2.getQueryServices()); @@ -153,11 +169,11 @@ public void testRPCConnections() throws SQLException { // Set BOOTSTRAP_NODES so that we can test the default case conf.set(RPCConnectionInfo.BOOTSTRAP_NODES, masterHosts); - try (PhoenixConnection conn1 = - (PhoenixConnection) DriverManager.getConnection("jdbc:phoenix+rpc"); - PhoenixConnection conn2 = + try (PhoenixMonitoredConnection conn1 = + (PhoenixMonitoredConnection) DriverManager.getConnection("jdbc:phoenix+rpc", PropertiesUtil.deepCopy(TEST_PROPERTIES)); + PhoenixMonitoredConnection conn2 = (PhoenixConnection) DriverManager.getConnection( - "jdbc:phoenix+rpc:" + masterHosts.replaceAll(":", "\\\\:"));) { + "jdbc:phoenix+rpc:" + masterHosts.replaceAll(":", "\\\\:"), PropertiesUtil.deepCopy(TEST_PROPERTIES));) { smoke(conn1); smoke(conn2); assertEquals(conn1.getQueryServices(), conn2.getQueryServices()); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionUtilIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionUtilIT.java index d8454a8ff53..95b0a7f006a 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionUtilIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionUtilIT.java @@ -18,7 +18,11 @@ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +import static org.apache.phoenix.query.BaseTest.getConfiguration; import static org.apache.phoenix.query.BaseTest.setUpConfigForMiniCluster; +import static org.apache.phoenix.query.BaseTest.setUpTestClusterForHA; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import java.sql.Connection; @@ -26,17 +30,21 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; +import java.util.Map; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HConstants; import org.apache.phoenix.jdbc.PhoenixDriver; import org.apache.phoenix.jdbc.PhoenixTestDriver; +import org.apache.phoenix.jdbc.ZKConnectionInfo; import org.apache.phoenix.mapreduce.util.ConnectionUtil; +import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; +import org.apache.phoenix.util.PropertiesUtil; +import org.apache.phoenix.util.ReadOnlyProps; import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(NeedsOwnMiniClusterTest.class) public class ConnectionUtilIT { @@ -45,18 +53,25 @@ public class ConnectionUtilIT { @BeforeClass public static synchronized void setUp() throws Exception { - hbaseTestUtil = new HBaseTestingUtility(); - conf = hbaseTestUtil.getConfiguration(); - setUpConfigForMiniCluster(conf); - conf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/hbase-test"); - hbaseTestUtil.startMiniCluster(); - Class.forName(PhoenixDriver.class.getName()); - DriverManager.registerDriver(new PhoenixTestDriver()); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + Map props = Maps.newHashMapWithExpectedSize(1); + props.put(HConstants.ZOOKEEPER_ZNODE_PARENT, "/hbase-test"); + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + conf = getConfiguration(); + } else { + hbaseTestUtil = new HBaseTestingUtility(); + conf = hbaseTestUtil.getConfiguration(); + setUpConfigForMiniCluster(conf); + conf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/hbase-test"); + hbaseTestUtil.startMiniCluster(); + Class.forName(PhoenixDriver.class.getName()); + DriverManager.registerDriver(new PhoenixTestDriver()); + } } @Test public void testInputAndOutputConnections() throws SQLException { - Connection inputConnection = ConnectionUtil.getInputConnection(conf); + Connection inputConnection = ConnectionUtil.getInputConnection(conf, PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = inputConnection.createStatement(); stmt.execute("create table t(a integer primary key,b varchar)"); stmt.execute("upsert into t values(1,'foo')"); @@ -64,7 +79,7 @@ public void testInputAndOutputConnections() throws SQLException { ResultSet rs = stmt.executeQuery("select count(*) from t"); rs.next(); assertEquals(1, rs.getInt(1)); - Connection outputConnection = ConnectionUtil.getOutputConnection(conf); + Connection outputConnection = ConnectionUtil.getOutputConnection(conf, PropertiesUtil.deepCopy(TEST_PROPERTIES)); stmt = outputConnection.createStatement(); stmt.execute("create table t1(a integer primary key,b varchar)"); stmt.execute("upsert into t1 values(1,'foo')"); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ContextClassloaderIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ContextClassloaderIT.java index 9592e47498c..283d4e600c5 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ContextClassloaderIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ContextClassloaderIT.java @@ -17,11 +17,13 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_ZK; import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR; import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_TERMINATOR; import static org.apache.phoenix.util.PhoenixRuntime.PHOENIX_TEST_DRIVER_URL_PARAM; import static org.apache.phoenix.util.TestUtil.LOCALHOST; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -33,6 +35,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; +import java.util.Map; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; @@ -40,12 +43,13 @@ import org.apache.phoenix.jdbc.PhoenixTestDriver; import org.apache.phoenix.query.BaseTest; import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(NeedsOwnMiniClusterTest.class) public class ContextClassloaderIT extends BaseTest { @@ -55,16 +59,19 @@ public class ContextClassloaderIT extends BaseTest { @BeforeClass public static synchronized void setUpBeforeClass() throws Exception { - Configuration conf = HBaseConfiguration.create(); - setUpConfigForMiniCluster(conf); - hbaseTestUtil = new HBaseTestingUtility(conf); - hbaseTestUtil.startMiniCluster(); - String clientPort = hbaseTestUtil.getConfiguration().get(QueryServices.ZOOKEEPER_PORT_ATTRIB); - String url = JDBC_PROTOCOL_ZK + JDBC_PROTOCOL_SEPARATOR + LOCALHOST + JDBC_PROTOCOL_SEPARATOR + clientPort - + JDBC_PROTOCOL_TERMINATOR + PHOENIX_TEST_DRIVER_URL_PARAM; - driver = initAndRegisterTestDriver(url, ReadOnlyProps.EMPTY_PROPS); - - Connection conn = DriverManager.getConnection(url); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(ReadOnlyProps.EMPTY_PROPS, ReadOnlyProps.EMPTY_PROPS); + } else { + Configuration conf = HBaseConfiguration.create(); + setUpConfigForMiniCluster(conf); + hbaseTestUtil = new HBaseTestingUtility(conf); + hbaseTestUtil.startMiniCluster(); + String clientPort = hbaseTestUtil.getConfiguration().get(QueryServices.ZOOKEEPER_PORT_ATTRIB); + String url = JDBC_PROTOCOL_ZK + JDBC_PROTOCOL_SEPARATOR + LOCALHOST + JDBC_PROTOCOL_SEPARATOR + clientPort + + JDBC_PROTOCOL_TERMINATOR + PHOENIX_TEST_DRIVER_URL_PARAM; + driver = initAndRegisterTestDriver(url, ReadOnlyProps.EMPTY_PROPS); + } + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE test (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR)"); stmt.execute("UPSERT INTO test VALUES (1, 'name1')"); @@ -77,6 +84,9 @@ public static synchronized void setUpBeforeClass() throws Exception { } protected static String getUrl() { + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + return CLUSTERS.getJdbcHAUrlWithoutPrincipal()+";"+PHOENIX_TEST_DRIVER_URL_PARAM; + } return "jdbc:phoenix:localhost:" + hbaseTestUtil.getZkCluster().getClientPort() + ";test=true"; } @@ -88,7 +98,7 @@ public void testQueryWithDifferentContextClassloader() throws SQLException, Inte @Override public void run() { try { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("select * from test where name = 'name2'"); while (rs.next()) { @@ -114,7 +124,7 @@ public void testGetDatabaseMetadataWithDifferentContextClassloader() throws Inte @Override public void run() { try { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet tablesRs = conn.getMetaData().getTables(null, null, null, null); while (tablesRs.next()) { // Just make sure we run over all records @@ -138,7 +148,7 @@ public void testExecuteDdlWithDifferentContextClassloader() throws InterruptedEx @Override public void run() { try { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE T2 (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR)"); stmt.execute("UPSERT INTO T2 VALUES (1, 'name1')"); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConvertTimezoneFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConvertTimezoneFunctionIT.java index 183c1a36ab6..7c3594ace2d 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConvertTimezoneFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConvertTimezoneFunctionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -29,6 +30,8 @@ import org.apache.phoenix.exception.SQLExceptionCode; import static org.junit.Assert.assertFalse; + +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -36,13 +39,12 @@ * CONVERT_TZ(date, 'from_timezone', 'to_timezone') tests * */ - @Category(ParallelStatsDisabledTest.class) public class ConvertTimezoneFunctionIT extends ParallelStatsDisabledIT { @Test public void testDateConvertTimezoneEurope() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String timezone_offset_test = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + timezone_offset_test + " (k1 INTEGER NOT NULL, dates DATE CONSTRAINT pk PRIMARY KEY (k1))"; @@ -62,7 +64,7 @@ public void testDateConvertTimezoneEurope() throws Exception { @Test public void testTimestampConvertTimezoneEurope() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String timezone_offset_test = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + timezone_offset_test + " (k1 INTEGER NOT NULL, timestamps TIMESTAMP CONSTRAINT pk PRIMARY KEY (k1))"; @@ -82,7 +84,7 @@ public void testTimestampConvertTimezoneEurope() throws Exception { @Test public void testConvertTimezoneAmerica() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String timezone_offset_test = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + timezone_offset_test + " (k1 INTEGER NOT NULL, dates DATE CONSTRAINT pk PRIMARY KEY (k1))"; @@ -102,7 +104,7 @@ public void testConvertTimezoneAmerica() throws Exception { @Test public void nullInDateParameter() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String timezone_offset_test = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + timezone_offset_test + " (k1 INTEGER NOT NULL, dates DATE CONSTRAINT pk PRIMARY KEY (k1))"; @@ -122,7 +124,7 @@ public void nullInDateParameter() throws Exception { @Test public void nullInFirstTimezoneParameter() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String timezone_offset_test = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + timezone_offset_test + " (k1 INTEGER NOT NULL, dates DATE, tz VARCHAR, CONSTRAINT pk PRIMARY KEY (k1))"; @@ -142,7 +144,7 @@ public void nullInFirstTimezoneParameter() throws Exception { @Test public void nullInSecondTimezoneParameter() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String timezone_offset_test = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + timezone_offset_test + " (k1 INTEGER NOT NULL, dates DATE, tz VARCHAR, CONSTRAINT pk PRIMARY KEY (k1))"; @@ -162,7 +164,7 @@ public void nullInSecondTimezoneParameter() throws Exception { @Test public void unknownTimezone() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String timezone_offset_test = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + timezone_offset_test + " (k1 INTEGER NOT NULL, dates DATE CONSTRAINT pk PRIMARY KEY (k1))"; @@ -187,7 +189,7 @@ public void unknownTimezone() throws Exception { @Test public void testConvertMultipleRecords() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String timezone_offset_test = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + timezone_offset_test + " (k1 INTEGER NOT NULL, dates DATE CONSTRAINT pk PRIMARY KEY (k1))"; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CostBasedDecisionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CostBasedDecisionIT.java index a76c40962e5..e15f6c2df4e 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CostBasedDecisionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CostBasedDecisionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -41,7 +42,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; - @Category(NeedsOwnMiniClusterTest.class) public class CostBasedDecisionIT extends BaseTest { private final String testTable500; @@ -56,7 +56,11 @@ public static synchronized void doSetup() throws Exception { props.put(QueryServices.USE_STATS_FOR_PARALLELIZATION, Boolean.toString(true)); props.put(QueryServices.COST_BASED_OPTIMIZER_ENABLED, Boolean.toString(true)); props.put(QueryServices.MAX_SERVER_CACHE_SIZE_ATTRIB, Long.toString(150000)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } public CostBasedDecisionIT() throws Exception { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CountDistinctApproximateHyperLogLogIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CountDistinctApproximateHyperLogLogIT.java index 03a3d576b8b..3e5d4a6db06 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CountDistinctApproximateHyperLogLogIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CountDistinctApproximateHyperLogLogIT.java @@ -31,7 +31,6 @@ import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.*; - @Category(ParallelStatsDisabledTest.class) public class CountDistinctApproximateHyperLogLogIT extends ParallelStatsDisabledIT { private String tableName; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CountDistinctCompressionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CountDistinctCompressionIT.java index e530d752528..d929d855e18 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CountDistinctCompressionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CountDistinctCompressionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -39,7 +40,6 @@ import org.junit.experimental.categories.Category; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; - @Category(NeedsOwnMiniClusterTest.class) public class CountDistinctCompressionIT extends BaseTest { @BeforeClass @@ -47,7 +47,11 @@ public static synchronized void doSetup() throws Exception { Map props = Maps.newHashMapWithExpectedSize(3); // Must update config before starting server props.put(QueryServices.DISTINCT_VALUE_COMPRESS_THRESHOLD_ATTRIB, Long.toString(1)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @Test diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateSchemaIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateSchemaIT.java index 0396d6401a4..e802bbe5a07 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateSchemaIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CreateSchemaIT.java @@ -28,7 +28,7 @@ import org.apache.hadoop.hbase.client.Admin; import org.apache.phoenix.exception.SQLExceptionCode; -import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.SchemaAlreadyExistsException; import org.apache.phoenix.util.ClientUtil; @@ -37,7 +37,6 @@ import org.apache.phoenix.util.TestUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class CreateSchemaIT extends ParallelStatsDisabledIT { @@ -55,7 +54,7 @@ public void testCreateSchema() throws Exception { String ddl1 = "CREATE SCHEMA \"" + schemaName1 + "\""; String ddl2 = "CREATE SCHEMA " + schemaName2; try (Connection conn = DriverManager.getConnection(getUrl(), props); - Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin();) { + Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin();) { conn.createStatement().execute(ddl1); assertTrue(ClientUtil.isHBaseNamespaceAvailable(admin, schemaName1)); conn.createStatement().execute(ddl2); @@ -72,7 +71,7 @@ public void testCreateSchema() throws Exception { // Create schema DEFAULT and HBASE (Should allow since they are upper-cased) and verify that it exists // Create schema default and hbase and it should fail try (Connection conn = DriverManager.getConnection(getUrl(), props); - Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin();) { + Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin();) { // default is a SQL keyword, hence it should always be passed in double-quotes try { 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 fdf49ccca8f..80f0bf2bdd7 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 @@ -18,6 +18,7 @@ package org.apache.phoenix.end2end; import static org.apache.phoenix.coprocessorclient.BaseScannerRegionObserverConstants.PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.mapreduce.index.IndexUpgradeTool.ROLLBACK_OP; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; @@ -60,8 +61,8 @@ import org.apache.hadoop.hbase.regionserver.BloomType; import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.exception.SQLExceptionCode; -import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixStatement; import org.apache.phoenix.mapreduce.index.IndexUpgradeTool; import org.apache.phoenix.query.BaseTest; @@ -93,7 +94,6 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(NeedsOwnMiniClusterTest.class) public class CreateTableIT extends ParallelStatsDisabledIT { @BeforeClass @@ -101,12 +101,16 @@ public static synchronized void doSetup() throws Exception { Map props = Maps.newHashMapWithExpectedSize(1); props.put(PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY, Integer.toString(60*60)); // An hour props.put(QueryServices.USE_STATS_FOR_PARALLELIZATION, Boolean.toString(false)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()), new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @Test public void testStartKeyStopKey() throws SQLException { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); conn.createStatement().execute("CREATE TABLE " + tableName @@ -131,7 +135,7 @@ public void testSplitsWithFile() throws Exception { writer.newLine(); writer.write("EZ"); } - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); conn.createStatement().execute("CREATE TABLE " + tableName @@ -164,7 +168,7 @@ public void testSplitsWithAbsoluteFileName() throws Exception { writer.newLine(); writer.write("EZ"); } - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); String createTableSql = "CREATE TABLE " + tableName @@ -191,7 +195,7 @@ public void testSplitsWithAbsoluteFileName() throws Exception { */ @Test public void testSplitsWithBadFileName() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); try { @@ -211,7 +215,7 @@ public void testSplitsWithBadFileName() throws Exception { */ @Test public void testSplitsWithBothSplitPointsAndSplitFileProvided() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); try { @@ -228,7 +232,7 @@ public void testSplitsWithBothSplitPointsAndSplitFileProvided() throws Exception @Test public void testCreateAlterTableWithDuplicateColumn() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); int failureCount = 0; int expectedExecCount = 0; String tableName = generateUniqueName(); @@ -360,7 +364,7 @@ public void testCreateAlterTableWithDuplicateColumn() throws Exception { public void testCreateTable() throws Exception { String schemaName = "TEST"; String tableName = schemaName + generateUniqueName(); - Properties props = new Properties(); + Properties props =PropertiesUtil.deepCopy(TEST_PROPERTIES); String ddl = "CREATE TABLE " + tableName + "( data.addtime VARCHAR ,\n" @@ -391,7 +395,7 @@ public void testCreateTable() throws Exception { try (Connection conn = DriverManager.getConnection(getUrl(), props);) { conn.createStatement().execute(ddl); } - Admin admin = driver.getConnectionQueryServices(getUrl(), props).getAdmin(); + Admin admin = driver.getConnectionQueryServices(getActiveUrl(), props).getAdmin(); assertNotNull(admin.getDescriptor(TableName.valueOf(tableName))); ColumnFamilyDescriptor[] columnFamilies = admin.getDescriptor(TableName.valueOf(tableName)).getColumnFamilies(); @@ -426,7 +430,7 @@ public void testCreateTable() throws Exception { @Test public void testCreateMultiTenantTable() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); String ddl = @@ -459,10 +463,10 @@ public void testCreateTableColumnFamilyHBaseAttribs1() throws Exception { + " col1 integer NOT NULL," + " col2 bigint NOT NULL," + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1, col2)" + " ) TTL=86400, SALT_BUCKETS = 4"; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); conn.createStatement().execute(ddl); - Admin admin = driver.getConnectionQueryServices(getUrl(), props).getAdmin(); + Admin admin = driver.getConnectionQueryServices(getActiveUrl(), props).getAdmin(); ColumnFamilyDescriptor[] columnFamilies = admin.getDescriptor(TableName.valueOf(tableName)).getColumnFamilies(); assertEquals(1, columnFamilies.length); @@ -480,11 +484,11 @@ public void testCreatingTooManyIndexesIsNotAllowed() throws Exception { + "COL2 BIGINT," + "COL3 BIGINT," + "COL4 BIGINT) "; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); conn.createStatement().execute(ddl); - int maxIndexes = conn.unwrap(PhoenixConnection.class).getQueryServices().getProps().getInt( + int maxIndexes = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getProps().getInt( QueryServices.MAX_INDEXES_PER_TABLE, QueryServicesOptions.DEFAULT_MAX_INDEXES_PER_TABLE); // Use local indexes since there's only one physical table for all of them. @@ -514,10 +518,10 @@ public void testCreateTableColumnFamilyHBaseAttribs2() throws Exception { + " col1 integer NOT NULL," + " b.col2 bigint," + " c.col3 bigint, " + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1)" + " ) TTL=86400, SALT_BUCKETS = 4"; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); conn.createStatement().execute(ddl); - Admin admin = driver.getConnectionQueryServices(getUrl(), props).getAdmin(); + Admin admin = driver.getConnectionQueryServices(getActiveUrl(), props).getAdmin(); ColumnFamilyDescriptor[] columnFamilies = admin.getDescriptor(TableName.valueOf(tableName)).getColumnFamilies(); assertEquals(2, columnFamilies.length); @@ -543,10 +547,10 @@ public void testCreateTableColumnFamilyHBaseAttribs3() throws Exception { + " col1 integer NOT NULL," + " b.col2 bigint," + " col3 bigint, " + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1)" + " ) TTL=86400, SALT_BUCKETS = 4"; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); conn.createStatement().execute(ddl); - Admin admin = driver.getConnectionQueryServices(getUrl(), props).getAdmin(); + Admin admin = driver.getConnectionQueryServices(getActiveUrl(), props).getAdmin(); ColumnFamilyDescriptor[] columnFamilies = admin.getDescriptor(TableName.valueOf(tableName)).getColumnFamilies(); assertEquals(2, columnFamilies.length); @@ -573,10 +577,10 @@ public void testCreateTableColumnFamilyHBaseAttribs4() throws Exception { + " col1 integer NOT NULL," + " b.col2 bigint," + " col3 bigint, " + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1)" + " ) b.BLOCKSIZE=50000, SALT_BUCKETS = 4"; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); conn.createStatement().execute(ddl); - Admin admin = driver.getConnectionQueryServices(getUrl(), props).getAdmin(); + Admin admin = driver.getConnectionQueryServices(getActiveUrl(), props).getAdmin(); ColumnFamilyDescriptor[] columnFamilies = admin.getDescriptor(TableName.valueOf(tableName)).getColumnFamilies(); assertEquals(2, columnFamilies.length); @@ -600,10 +604,10 @@ public void testCreateTableColumnFamilyHBaseAttribs5() throws Exception { + " col1 integer NOT NULL," + " b.col2 bigint," + " c.col3 bigint, " + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1)" + " ) b.BLOCKSIZE=50000, c.BLOCKSIZE=60000, SALT_BUCKETS = 4"; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); conn.createStatement().execute(ddl); - Admin admin = driver.getConnectionQueryServices(getUrl(), props).getAdmin(); + Admin admin = driver.getConnectionQueryServices(getActiveUrl(), props).getAdmin(); ColumnFamilyDescriptor[] columnFamilies = admin.getDescriptor(TableName.valueOf(tableName)).getColumnFamilies(); assertEquals(2, columnFamilies.length); @@ -625,10 +629,10 @@ public void testCreateTableColumnFamilyHBaseAttribs6() throws Exception { + " col1 integer NOT NULL," + " col2 bigint," + " col3 bigint, " + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1)" + " ) DEFAULT_COLUMN_FAMILY='a', TTL=10000, SALT_BUCKETS = 4"; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); conn.createStatement().execute(ddl); - Admin admin = driver.getConnectionQueryServices(getUrl(), props).getAdmin(); + Admin admin = driver.getConnectionQueryServices(getActiveUrl(), props).getAdmin(); ColumnFamilyDescriptor[] columnFamilies = admin.getDescriptor(TableName.valueOf(tableName)).getColumnFamilies(); assertEquals(1, columnFamilies.length); @@ -650,10 +654,10 @@ public void testCreateTableColumnFamilyHBaseAttribs7() throws Exception { "create table IF NOT EXISTS " + tableName + " (" + " id char(1) NOT NULL," + " col1 integer NOT NULL," + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1)" + " ) DEFAULT_COLUMN_FAMILY='a', TTL=10000, SALT_BUCKETS = 4"; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); conn.createStatement().execute(ddl); - Admin admin = driver.getConnectionQueryServices(getUrl(), props).getAdmin(); + Admin admin = driver.getConnectionQueryServices(getActiveUrl(), props).getAdmin(); ColumnFamilyDescriptor[] columnFamilies = admin.getDescriptor(TableName.valueOf(tableName)).getColumnFamilies(); assertEquals(1, columnFamilies.length); @@ -672,10 +676,10 @@ public void testCreateTableColumnFamilyHBaseAttribs8() throws Exception { + " col1 integer NOT NULL," + " col2 bigint NOT NULL," + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1, col2)" + " ) BLOOMFILTER = 'NONE', SALT_BUCKETS = 4"; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); conn.createStatement().execute(ddl); - Admin admin = driver.getConnectionQueryServices(getUrl(), props).getAdmin(); + Admin admin = driver.getConnectionQueryServices(getActiveUrl(), props).getAdmin(); ColumnFamilyDescriptor[] columnFamilies = admin.getDescriptor(TableName.valueOf(tableName)).getColumnFamilies(); assertEquals(BloomType.NONE, columnFamilies[0].getBloomFilterType()); @@ -700,7 +704,7 @@ public void testNotNullConstraintForNonPKColumn() throws Exception { + " ORGANIZATION_ID, EVENT_TIME,USER_ID,ENTRY_POINT_ID, ENTRY_POINT_TYPE, APEX_LIMIT_ID " + " ) ) VERSIONS=1"; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); try { conn.createStatement().execute(ddl); @@ -716,7 +720,7 @@ public void testNotNullConstraintForWithSinglePKCol() throws Exception { String tableName = generateUniqueName(); String ddl = "create table " + tableName + " (k integer primary key, v bigint not null)"; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); try { conn.createStatement().execute(ddl); @@ -735,7 +739,7 @@ public void testSpecifyingColumnFamilyForTTLFails() throws Exception { + " col1 integer NOT NULL," + " CF.col2 integer," + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1)" + " ) DEFAULT_COLUMN_FAMILY='a', CF.TTL=10000, SALT_BUCKETS = 4"; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); try { conn.createStatement().execute(ddl); @@ -822,7 +826,7 @@ public void testCreateTableIfNotExistsForEncodedColumnNames() throws Exception { private void assertColumnEncodingMetadata(QualifierEncodingScheme expectedEncodingScheme, ImmutableStorageScheme expectedStorageScheme, String tableName, Connection conn) throws Exception { - PhoenixConnection phxConn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection phxConn = conn.unwrap(PhoenixMonitoredConnection.class); PTable table = phxConn.getTable(new PTableKey(null, tableName)); assertEquals(expectedEncodingScheme, table.getEncodingScheme()); assertEquals(expectedStorageScheme, table.getImmutableStorageScheme()); @@ -911,7 +915,7 @@ public void testCreateChangeDetectionEnabledTable() throws Exception { String schemaName = generateUniqueName(); String tableName = generateUniqueName(); String fullTableName = SchemaUtil.getTableName(schemaName, tableName); - try (PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl())) { + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES))) { String ddl = "CREATE TABLE " + fullTableName + " (id char(1) NOT NULL," + " col1 integer NOT NULL," + " col2 bigint NOT NULL," + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1, col2)) " + @@ -935,7 +939,6 @@ public void testCreateIndexWithDifferentStorageAndEncoding() throws Exception { String createTableDDL = "create IMMUTABLE TABLE " + tableName + "(id char(1) NOT NULL, col1 char(1), col2 char(1) " + "CONSTRAINT NAME_PK PRIMARY KEY (id)) IMMUTABLE_STORAGE_SCHEME=SINGLE_CELL_ARRAY_WITH_OFFSETS"; String createIndexDDL = "create INDEX " + indexName + " ON " + tableName + " (col1) INCLUDE (col2) IMMUTABLE_STORAGE_SCHEME=ONE_CELL_PER_COLUMN"; - Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { conn.createStatement().execute(createTableDDL); @@ -1043,7 +1046,6 @@ public void testCreateTableNoUpdateCacheFreq() throws Exception { public void testCreateTableWithTableLevelUpdateCacheFreq() throws Exception { String tableName = generateUniqueName(); Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES); - HashMap expectedUCF = new HashMap<>(); expectedUCF.put("10", new Long(10L)); expectedUCF.put("0", new Long(0L)); @@ -1113,7 +1115,7 @@ public void testCreateTableWithNamespaceMappingEnabled() throws Exception { final String TBL = "TBL_" + generateUniqueName(); final String CF = "CF"; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.TRUE.toString()); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { @@ -1167,7 +1169,7 @@ public void testCreateTableWithNamespaceMappingEnabled() throws Exception { @Test public void testSetTableDescriptorPropertyOnView() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); final String dataTableFullName = generateUniqueName(); String ddl = "CREATE TABLE " + dataTableFullName + " (\n" + "ID1 VARCHAR(15) NOT NULL,\n" @@ -1193,7 +1195,7 @@ public void testSetTableDescriptorPropertyOnView() throws Exception { @Test public void testCreateViewFromNonExistentTable() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute( "CREATE TABLE IF NOT EXISTS S.T1 (A INTEGER PRIMARY KEY, B INTEGER)"); // 1. create view from non-existent table (without schema) @@ -1226,7 +1228,7 @@ public void testCreateViewFromNonExistentTable() throws Exception { @Test public void testSettingGuidePostWidth() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String dataTable = generateUniqueName(); int guidePostWidth = 20; String ddl = @@ -1292,13 +1294,13 @@ public void testTableDescriptorPriority() throws SQLException, IOException { String fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, tableName); String fullIndexeName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, indexName); // Check system tables priorities. - try (Admin admin = driver.getConnectionQueryServices(getUrl(), new Properties()).getAdmin(); - Connection c = DriverManager.getConnection(getUrl())) { + try (Admin admin = driver.getConnectionQueryServices(getActiveUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).getAdmin(); + Connection c = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { ResultSet rs = c.getMetaData().getTables("", "\""+ PhoenixDatabaseMetaData.SYSTEM_CATALOG_SCHEMA + "\"", null, new String[] {PTableType.SYSTEM.toString()}); - ReadOnlyProps p = c.unwrap(PhoenixConnection.class).getQueryServices().getProps(); + ReadOnlyProps p = c.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getProps(); while (rs.next()) { String schemaName = rs.getString(PhoenixDatabaseMetaData.TABLE_SCHEM); String tName = rs.getString(PhoenixDatabaseMetaData.TABLE_NAME); @@ -1307,7 +1309,7 @@ public void testTableDescriptorPriority() throws SQLException, IOException { String val = htd.getValue("PRIORITY"); assertNotNull("PRIORITY is not set for table:" + htd, val); assertTrue(Integer.parseInt(val) - >= IndexUtil.getMetadataPriority(config)); + >= IndexUtil.getMetadataPriority(getConfiguration())); } Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); String ddl ="CREATE TABLE " + fullTableName + TestUtil.TEST_TABLE_SCHEMA; @@ -1331,13 +1333,13 @@ public void testTableDescriptorPriority() throws SQLException, IOException { org.apache.hadoop.hbase.TableName.valueOf(fullIndexeName)); val = indexTable.getValue("PRIORITY"); assertNotNull("PRIORITY is not set for table:" + indexTable, val); - assertTrue(Integer.parseInt(val) >= IndexUtil.getIndexPriority(config)); + assertTrue(Integer.parseInt(val) >= IndexUtil.getIndexPriority(getConfiguration())); } } @Test public void testCreateTableSchemaVersionAndTopicName() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); final String schemaName = generateUniqueName(); final String tableName = generateUniqueName(); final String version = "V1.0"; @@ -1361,7 +1363,7 @@ public static void testCreateTableSchemaVersionAndTopicNameHelper(Connection con ddl += ", STREAMING_TOPIC_NAME='" + topicName + "'"; } conn.createStatement().execute(ddl); - PTable table = conn.unwrap(PhoenixConnection.class).getTableNoCache(dataTableFullName); + PTable table = conn.unwrap(PhoenixMonitoredConnection.class).getTableNoCache(dataTableFullName); assertEquals(dataTableVersion, table.getSchemaVersion()); if (topicName != null) { assertEquals(topicName, table.getStreamingTopicName()); @@ -1372,7 +1374,7 @@ public static void testCreateTableSchemaVersionAndTopicNameHelper(Connection con @Test public void testCreateTableDDLTimestamp() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); final String schemaName = generateUniqueName(); final String tableName = generateUniqueName(); final String dataTableFullName = SchemaUtil.getTableName(schemaName, tableName); @@ -1390,7 +1392,7 @@ public void testCreateTableDDLTimestamp() throws Exception { @Test public void testCreateTableWithColumnQualifiers() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); String ddl = "CREATE TABLE \"" + tableName + "\"(K VARCHAR NOT NULL PRIMARY KEY, " + @@ -1398,7 +1400,7 @@ public void testCreateTableWithColumnQualifiers() throws Exception { "INT3 INTEGER ENCODED_QUALIFIER 14) COLUMN_QUALIFIER_COUNTER ('" + QueryConstants.DEFAULT_COLUMN_FAMILY + "'=15)"; conn.createStatement().execute(ddl); - PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pconn = conn.unwrap(PhoenixMonitoredConnection.class); PTable table = pconn.getTable(new PTableKey(null, tableName)); QualifierEncodingScheme encodingScheme = table.getEncodingScheme(); @@ -1416,7 +1418,7 @@ public void testCreateTableWithColumnQualifiers() throws Exception { @Test public void testCreateTableWithNotOrderedColumnQualifiers() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); String ddl = "CREATE TABLE \"" + tableName + "\"(K VARCHAR NOT NULL PRIMARY KEY, " + @@ -1424,7 +1426,7 @@ public void testCreateTableWithNotOrderedColumnQualifiers() throws Exception { "INT2 INTEGER ENCODED_QUALIFIER 12) COLUMN_QUALIFIER_COUNTER ('" + QueryConstants.DEFAULT_COLUMN_FAMILY + "'=15)"; conn.createStatement().execute(ddl); - PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pconn = conn.unwrap(PhoenixMonitoredConnection.class); PTable table = pconn.getTable(new PTableKey(null, tableName)); QualifierEncodingScheme encodingScheme = table.getEncodingScheme(); @@ -1442,14 +1444,14 @@ public void testCreateTableWithNotOrderedColumnQualifiers() throws Exception { @Test public void testCreateTableWithColumnQualifiersWithoutCounter() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); String ddl = "CREATE TABLE \"" + tableName + "\"(K VARCHAR NOT NULL PRIMARY KEY, " + "INT INTEGER ENCODED_QUALIFIER 11, INT2 INTEGER ENCODED_QUALIFIER 12, " + "INT3 INTEGER ENCODED_QUALIFIER 14)"; conn.createStatement().execute(ddl); - PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pconn = conn.unwrap(PhoenixMonitoredConnection.class); PTable table = pconn.getTable(new PTableKey(null, tableName)); QualifierEncodingScheme encodingScheme = table.getEncodingScheme(); @@ -1467,7 +1469,7 @@ public void testCreateTableWithColumnQualifiersWithoutCounter() throws Exception @Test public void testCreateTableWithColumnQualifiersMultipleFamilies() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); String ddl = "CREATE IMMUTABLE TABLE \"" + tableName + "\"(K VARCHAR NOT NULL PRIMARY KEY, " + @@ -1475,7 +1477,7 @@ public void testCreateTableWithColumnQualifiersMultipleFamilies() throws Excepti "B.INT3 INTEGER ENCODED_QUALIFIER 12) " + "COLUMN_QUALIFIER_COUNTER ('A'=14, 'B'=13)"; conn.createStatement().execute(ddl); - PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pconn = conn.unwrap(PhoenixMonitoredConnection.class); PTable table = pconn.getTable(new PTableKey(null, tableName)); QualifierEncodingScheme encodingScheme = table.getEncodingScheme(); @@ -1494,14 +1496,14 @@ public void testCreateTableWithColumnQualifiersMultipleFamilies() throws Excepti @Test public void testCreateTableWithColumnQualifiersMultipleFamiliesWithoutCounter() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); String ddl = "CREATE IMMUTABLE TABLE \"" + tableName + "\"(K VARCHAR NOT NULL PRIMARY KEY, " + "A.INT INTEGER ENCODED_QUALIFIER 11, A.INT2 INTEGER ENCODED_QUALIFIER 13, " + "B.INT3 INTEGER ENCODED_QUALIFIER 12)"; conn.createStatement().execute(ddl); - PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pconn = conn.unwrap(PhoenixMonitoredConnection.class); PTable table = pconn.getTable(new PTableKey(null, tableName)); QualifierEncodingScheme encodingScheme = table.getEncodingScheme(); @@ -1520,7 +1522,7 @@ public void testCreateTableWithColumnQualifiersMultipleFamiliesWithoutCounter() @Test public void testCreateTableWithColumnQualifiersDuplicateCQ() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); String ddl = "CREATE TABLE \"" + tableName + "\"(K VARCHAR NOT NULL PRIMARY KEY, " + @@ -1539,7 +1541,7 @@ public void testCreateTableWithColumnQualifiersDuplicateCQ() throws Exception { @Test public void testCreateTableInvalidColumnQualifier() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); String ddl = "CREATE TABLE \"" + tableName + "\"(K VARCHAR NOT NULL PRIMARY KEY, " + @@ -1593,7 +1595,7 @@ public void testCreateTableInvalidColumnQualifier() throws Exception { @Test public void testCreateTableMissingColumnQualifier() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); String ddl = "CREATE TABLE \"" + tableName + "\"(K VARCHAR NOT NULL PRIMARY KEY, " + @@ -1623,7 +1625,7 @@ public void testCreateTableMissingColumnQualifier() throws Exception { @Test public void testCreateTableDefaultColumnQualifier() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); String ddl = "CREATE IMMUTABLE TABLE \"" + tableName + "\"(K VARCHAR NOT NULL PRIMARY KEY, " + @@ -1635,7 +1637,7 @@ public void testCreateTableDefaultColumnQualifier() throws Exception { "\"B\".INT6 INTEGER) " + "DEFAULT_COLUMN_FAMILY=dF"; conn.createStatement().execute(ddl); - PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pconn = conn.unwrap(PhoenixMonitoredConnection.class); PTable table = pconn.getTable(new PTableKey(null, tableName)); QualifierEncodingScheme encodingScheme = table.getEncodingScheme(); @@ -1673,10 +1675,10 @@ public void testCoprocessorsForCreateIndexOnOldImplementation() throws Exception String index1Ddl = "create index " + index1Name + " on " + tableName + " (v1)"; String index2Ddl = "create index " + index2Name + " on " + tableName + " (v2)"; - Properties props = new Properties(); - Admin admin = driver.getConnectionQueryServices(getUrl(), props).getAdmin(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); + Admin admin = driver.getConnectionQueryServices(getActiveUrl(), props).getAdmin(); - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement();) { stmt.execute(ddl); stmt.execute(index1Ddl); @@ -1719,10 +1721,10 @@ public void testCoprocessorsForTransactionalCreateIndexOnOldImplementation() thr + " v2 integer) TRANSACTIONAL=TRUE"; String index1Ddl = "create index " + index1Name + " on " + tableName + " (v1)"; - Properties props = new Properties(); - Admin admin = driver.getConnectionQueryServices(getUrl(), props).getAdmin(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); + Admin admin = driver.getConnectionQueryServices(getActiveUrl(), props).getAdmin(); - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement();) { stmt.execute(ddl); stmt.execute(index1Ddl); @@ -1759,8 +1761,7 @@ public void testCreateTableWithNoVerify() throws SQLException, IOException, Inte final byte[] tableBytes = tableName.getBytes(); final byte[] familyName = Bytes.toBytes(SchemaUtil.normalizeIdentifier("0")); final byte[][] splits = new byte[][] {Bytes.toBytes(20), Bytes.toBytes(30)}; - - try (Admin admin = driver.getConnectionQueryServices(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).getAdmin()) { + try (Admin admin = driver.getConnectionQueryServices(getActiveUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).getAdmin()) { admin.createTable(TableDescriptorBuilder.newBuilder(TableName.valueOf(tableBytes)) .addColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(familyName) .setKeepDeletedCells(KeepDeletedCells.TRUE).build()) @@ -1773,7 +1774,7 @@ public void testCreateTableWithNoVerify() throws SQLException, IOException, Inte final byte[] key_2 = ByteUtil.concat(Bytes.toBytes(40), Bytes.toBytes(400L), Bytes.toBytes("d")); final byte[] emptyColumnQualifier = Bytes.toBytes("_0"); - ConnectionQueryServices services = driver.getConnectionQueryServices(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + ConnectionQueryServices services = driver.getConnectionQueryServices(getActiveUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); try (Table hTable = services.getTable(tableBytes)) { // Insert rows using standard HBase mechanism with standard HBase "types" List mutations = new ArrayList<>(); @@ -1805,7 +1806,7 @@ public void testCreateTableWithNoVerify() throws SQLException, IOException, Inte " ulong_col unsigned_long" + " CONSTRAINT pk PRIMARY KEY (uint_key, ulong_key, string_key)) noverify COLUMN_ENCODED_BYTES=NONE"; - try (Connection conn = DriverManager.getConnection(url)) { + try (Connection conn = DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute(ddl); } @@ -1842,14 +1843,14 @@ public static long verifyLastDDLTimestamp(String tableFullName, long startTS, Co } public static long getLastDDLTimestamp(Connection conn, String tableFullName) throws SQLException { - PTable table = conn.unwrap(PhoenixConnection.class).getTableNoCache(tableFullName); + PTable table = conn.unwrap(PhoenixMonitoredConnection.class).getTableNoCache(tableFullName); assertNotNull("PTable is null!", table); assertNotNull("DDL timestamp is null!", table.getLastDDLTimestamp()); return table.getLastDDLTimestamp(); } private int checkGuidePostWidth(String tableName) throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String query = "SELECT GUIDE_POSTS_WIDTH FROM SYSTEM.CATALOG WHERE TABLE_NAME = ? AND COLUMN_FAMILY IS NULL AND COLUMN_NAME IS NULL"; PreparedStatement stmt = conn.prepareStatement(query); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CsvBulkLoadToolIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CsvBulkLoadToolIT.java index 86acbe1df3c..4c1dc31c391 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CsvBulkLoadToolIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CsvBulkLoadToolIT.java @@ -17,7 +17,9 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.query.QueryServices.DATE_FORMAT_ATTRIB; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -39,6 +41,7 @@ import org.apache.hadoop.hbase.client.Admin; import org.apache.phoenix.end2end.index.IndexTestUtil; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.mapreduce.CsvBulkLoadTool; import org.apache.phoenix.query.QueryConstants; import org.apache.phoenix.query.QueryServices; @@ -47,6 +50,7 @@ import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; import org.apache.phoenix.util.DateUtil; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.QueryUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; @@ -54,7 +58,6 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(NeedsOwnMiniClusterTest.class) public class CsvBulkLoadToolIT extends BaseOwnClusterIT { @@ -65,9 +68,13 @@ public class CsvBulkLoadToolIT extends BaseOwnClusterIT { public static synchronized void doSetup() throws Exception { Map clientProps = Maps.newHashMapWithExpectedSize(1); clientProps.put(QueryServices.INDEX_REGION_OBSERVER_ENABLED_ATTRIB, Boolean.FALSE.toString()); - setUpTestDriver(ReadOnlyProps.EMPTY_PROPS, new ReadOnlyProps(clientProps.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(ReadOnlyProps.EMPTY_PROPS, new ReadOnlyProps(clientProps.entrySet().iterator())); + } else { + setUpTestDriver(ReadOnlyProps.EMPTY_PROPS, new ReadOnlyProps(clientProps.entrySet().iterator())); + } zkQuorum = TestUtil.LOCALHOST + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + getUtility().getZkCluster().getClientPort(); - conn = DriverManager.getConnection(getUrl()); + conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); } @Test @@ -527,7 +534,7 @@ public void testImportWithDifferentPhysicalName() throws Exception { stmt.execute(ddl); String newTableName = LogicalTableNameIT.NEW_TABLE_PREFIX + generateUniqueName(); String fullNewTableName = SchemaUtil.getTableName(schemaName, newTableName); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { String snapshotName = new StringBuilder(tableName).append("-Snapshot").toString(); admin.snapshot(snapshotName, TableName.valueOf(fullTableName)); admin.cloneSnapshot(snapshotName, TableName.valueOf(fullNewTableName)); @@ -687,7 +694,7 @@ public void testImportInSingleCellArrayWithOffsetsTable() throws Exception { stmt.execute("CREATE IMMUTABLE TABLE S.TABLE12 (ID INTEGER NOT NULL PRIMARY KEY," + " CF0.NAME VARCHAR, CF0.T DATE, CF1.T2 DATE, CF2.T3 DATE) " + "IMMUTABLE_STORAGE_SCHEME=SINGLE_CELL_ARRAY_WITH_OFFSETS"); - PhoenixConnection phxConn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection phxConn = conn.unwrap(PhoenixMonitoredConnection.class); PTable table = phxConn.getTable(new PTableKey(null, "S.TABLE12")); assertEquals(PTable.ImmutableStorageScheme.SINGLE_CELL_ARRAY_WITH_OFFSETS, diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CursorWithRowValueConstructorIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CursorWithRowValueConstructorIT.java index 12aa43b1305..c9107aa8071 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CursorWithRowValueConstructorIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CursorWithRowValueConstructorIT.java @@ -54,13 +54,12 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class CursorWithRowValueConstructorIT extends ParallelStatsDisabledIT { private String tableName = generateUniqueName(); public void createAndInitializeTestTable() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); tableName = generateUniqueName(); PreparedStatement stmt = conn.prepareStatement("CREATE TABLE " + tableName + "(a_id INTEGER NOT NULL, " + @@ -87,7 +86,7 @@ public void createAndInitializeTestTable() throws SQLException { @Test public void testCursorsOnTestTablePK() throws SQLException { String cursorName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { createAndInitializeTestTable(); String querySQL = "SELECT a_id FROM " + tableName; @@ -112,7 +111,7 @@ public void testCursorsOnTestTablePK() throws SQLException { @Test public void testCursorsOnRandomTableData() throws SQLException { String cursorName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { createAndInitializeTestTable(); String querySQL = "SELECT a_id,a_data FROM " + tableName + " ORDER BY a_data"; String cursorSQL = "DECLARE " + cursorName + " CURSOR FOR " + querySQL; @@ -136,7 +135,7 @@ public void testCursorsOnRandomTableData() throws SQLException { @Test public void testCursorsOnTestTablePKDesc() throws SQLException { String cursorName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { createAndInitializeTestTable(); String dummySQL = "SELECT a_id FROM " + tableName + " ORDER BY a_id DESC"; @@ -160,7 +159,7 @@ public void testCursorsOnTestTablePKDesc() throws SQLException { @Test public void testCursorsOnTestTableNonPKDesc() throws SQLException { String cursorName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { createAndInitializeTestTable(); String dummySQL = "SELECT a_data FROM " + tableName + " ORDER BY a_data DESC"; @@ -183,7 +182,7 @@ public void testCursorsOnTestTableNonPKDesc() throws SQLException { @Test public void testCursorsOnWildcardSelect() throws SQLException { String cursorName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { createAndInitializeTestTable(); String querySQL = "SELECT * FROM " + tableName; ResultSet rs = conn.prepareStatement(querySQL).executeQuery(); @@ -212,7 +211,7 @@ public void testCursorsWithBindings() throws Exception { final String aTable = initATableValues(null, tenantId, getDefaultSplits(tenantId), null, null, getUrl(), null); String query = "SELECT a_integer, x_integer FROM "+ aTable +" WHERE ?=organization_id AND (a_integer, x_integer) = (7, 5)"; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String cursor = "DECLARE " + cursorName + " CURSOR FOR "+query; try { PreparedStatement statement = conn.prepareStatement(cursor); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CustomEntityDataIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CustomEntityDataIT.java index 182570776ac..d9a5a555117 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CustomEntityDataIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CustomEntityDataIT.java @@ -37,7 +37,6 @@ import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class CustomEntityDataIT extends ParallelStatsDisabledIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DateArithmeticIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DateArithmeticIT.java index 312c3ec62ca..c3c7c63ba6f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DateArithmeticIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DateArithmeticIT.java @@ -46,7 +46,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; import org.apache.phoenix.thirdparty.com.google.common.collect.Lists; - @Category(ParallelStatsDisabledTest.class) public class DateArithmeticIT extends ParallelStatsDisabledIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DateTimeIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DateTimeIT.java index 09405844623..41efdf0a629 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DateTimeIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DateTimeIT.java @@ -67,7 +67,7 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.compile.StatementContext; -import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixStatement; import org.apache.phoenix.query.QueryConstants; import org.apache.phoenix.query.QueryServices; @@ -84,7 +84,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class DateTimeIT extends ParallelStatsDisabledIT { private static final String PRODUCT_METRICS_NAME = "PRODUCT_METRICS"; @@ -207,7 +206,7 @@ public DateTimeIT() throws Exception { @Before public void setUp() throws SQLException { - conn = DriverManager.getConnection(getUrl()); + conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)); this.tableName = initAtable(); } @@ -1786,7 +1785,7 @@ public void testDateAddCompareDate() throws Exception { String tablename=generateUniqueName(); String tenantId = getOrganizationId(); String query = "SELECT feature FROM "+tablename+" WHERE organization_id = ? and date + 1 >= ?"; - Connection conn = DriverManager.getConnection(url); + Connection conn = DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { Date startDate = new Date(System.currentTimeMillis()); Date endDate = new Date(startDate.getTime() + 8 * QueryConstants.MILLIS_IN_DAY); @@ -1852,7 +1851,7 @@ public void testCastTimeStampToDate() throws Exception { String tablename = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tablename + " (PK INTEGER PRIMARY KEY, A_TIMESTAMP TIMESTAMP)"; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty("phoenix.query.dateFormatTimeZone", TimeZone.getDefault().toString()); Connection conn = DriverManager.getConnection(getUrl(), props); conn.createStatement().execute(ddl); @@ -2154,7 +2153,7 @@ public void testAncientDatesWithJavaTime() throws Exception { } public void testDateFormatTimeZone(String timeZoneId) throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty("phoenix.query.dateFormatTimeZone", timeZoneId); Connection conn1 = DriverManager.getConnection(getUrl(), props); @@ -2167,7 +2166,7 @@ public void testDateFormatTimeZone(String timeZoneId) throws Exception { try { conn1.createStatement().execute(ddl); - PhoenixConnection pConn = conn1.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pConn = conn1.unwrap(PhoenixMonitoredConnection.class); verifyTimeZoneIDWithConn(pConn, PDate.INSTANCE, timeZoneId); verifyTimeZoneIDWithConn(pConn, PTime.INSTANCE, timeZoneId); verifyTimeZoneIDWithConn(pConn, PTimestamp.INSTANCE, timeZoneId); @@ -2205,7 +2204,7 @@ public void testDateFormatTimeZone(String timeZoneId) throws Exception { } } - private void verifyTimeZoneIDWithConn(PhoenixConnection conn, PDataType dataType, String timeZoneId) { + private void verifyTimeZoneIDWithConn(PhoenixMonitoredConnection conn, PDataType dataType, String timeZoneId) throws SQLException { Format formatter = conn.getFormatter(dataType); verifyTimeZoneIDWithFormatter(formatter, timeZoneId); } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DecodeBinaryFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DecodeBinaryFunctionIT.java index 5f1067be7a8..c0133e2e246 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DecodeBinaryFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DecodeBinaryFunctionIT.java @@ -16,6 +16,7 @@ */ package org.apache.phoenix.end2end; +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; @@ -27,10 +28,10 @@ import java.util.Arrays; import org.apache.commons.lang3.StringUtils; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class DecodeBinaryFunctionIT extends ParallelStatsDisabledIT { @@ -42,7 +43,7 @@ public class DecodeBinaryFunctionIT extends ParallelStatsDisabledIT { @BeforeClass public static void setUpBeforeClass() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); testTable = generateUniqueName(); String ddl = "CREATE TABLE " + testTable + " (id INTEGER PRIMARY KEY, data VARCHAR)"; conn.createStatement().execute(ddl); @@ -56,8 +57,7 @@ public static void setUpBeforeClass() throws Exception { @Test public void testDecodeHBaseFromHexLiteral() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); - + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery( "SELECT DECODE_BINARY('\\x48\\x65\\x6C\\x6C\\x6F\\x50\\x68\\x6F\\x65\\x6E\\x69\\x78', " + "'HBASE') FROM " + testTable); @@ -68,7 +68,7 @@ public void testDecodeHBaseFromHexLiteral() throws Exception { @Test public void testNullAndEmptyStringDecoding() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement() .executeQuery("SELECT DECODE_BINARY(data, 'HBASE') FROM " + testTable + " WHERE ID=-10"); @@ -87,7 +87,7 @@ public void testNullAndEmptyStringDecoding() throws Exception { @Test public void testLongBase64Decoding() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); StringBuilder base64String = new StringBuilder(); for (int i = 0; i < 20; i++) { @@ -115,7 +115,7 @@ public void testLongBase64Decoding() throws Exception { @Test public void testDecodeBase64WithPadding() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); PreparedStatement ps = conn.prepareStatement("UPSERT INTO " + testTable + " (id, data) VALUES (7, ?)"); ps.setString(1, "SQ=="); @@ -133,7 +133,7 @@ public void testDecodeBase64WithPadding() throws Exception { @Test public void testDecodeEncodeRoundHex() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); PreparedStatement ps = conn.prepareStatement("UPSERT INTO " + testTable + " (id, data) VALUES (4, ?)"); ps.setString(1, hex48String); @@ -150,7 +150,7 @@ public void testDecodeEncodeRoundHex() throws Exception { @Test public void testDecodeEncodeRoundBase64() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); PreparedStatement ps = conn.prepareStatement("UPSERT INTO " + testTable + " (id, data) VALUES (5, ?)"); ps.setString(1, base64Chunk); @@ -167,8 +167,7 @@ public void testDecodeEncodeRoundBase64() throws Exception { @Test public void testDecodeEncodeRoundHbase() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); - + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery( "SELECT ENCODE_BINARY(DECODE_BINARY(data, 'HBASE'), 'HBASE') FROM " + testTable + " WHERE ID=1"); assertTrue(rs.next()); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DecodeFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DecodeFunctionIT.java index f4e949958cb..05060261336 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DecodeFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DecodeFunctionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +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; @@ -33,16 +34,16 @@ import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.schema.types.PInteger; import org.apache.phoenix.schema.types.PUnsignedLong; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class DecodeFunctionIT extends ParallelStatsDisabledIT { @Test public void shouldPass() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String testTable = generateUniqueName(); String ddl = "CREATE TABLE " + testTable @@ -65,7 +66,7 @@ public void shouldPass() throws Exception { @Test public void upperCaseHexEncoding() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String testTable = generateUniqueName(); String ddl = "CREATE TABLE " + testTable @@ -88,7 +89,7 @@ public void upperCaseHexEncoding() throws Exception { @Test public void invalidCharacters() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String testTable = generateUniqueName(); String ddl = "CREATE TABLE " + testTable + " ( some_column BINARY(12) NOT NULL CONSTRAINT PK PRIMARY KEY (some_column))"; @@ -106,7 +107,7 @@ public void invalidCharacters() throws Exception { @Test public void invalidLength() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String testTable = generateUniqueName(); String ddl = "CREATE TABLE " + testTable + " ( some_column BINARY(12) NOT NULL CONSTRAINT PK PRIMARY KEY (some_column))"; @@ -124,7 +125,7 @@ public void invalidLength() throws Exception { @Test public void nullEncoding() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String testTable = generateUniqueName(); String ddl = "CREATE TABLE " + testTable + " ( some_column BINARY(12) NOT NULL CONSTRAINT PK PRIMARY KEY (some_column))"; @@ -138,7 +139,7 @@ public void nullEncoding() throws Exception { @Test public void invalidEncoding() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String testTable = generateUniqueName(); String ddl = "CREATE TABLE " + testTable + " ( some_column BINARY(12) NOT NULL CONSTRAINT PK PRIMARY KEY (some_column))"; @@ -155,7 +156,7 @@ public void invalidEncoding() throws Exception { @Test public void testDecodeBase642() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String testTable = generateUniqueName(); String ddl = "CREATE TABLE " + testTable + " (id INTEGER PRIMARY KEY, data VARCHAR)"; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DefaultColumnValueIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DefaultColumnValueIT.java index 9231eed48cc..ddc3cefc923 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DefaultColumnValueIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DefaultColumnValueIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -37,11 +38,11 @@ import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.util.ByteUtil; import org.apache.phoenix.util.DateUtil; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class DefaultColumnValueIT extends ParallelStatsDisabledIT { private String sharedTable1; @@ -64,7 +65,7 @@ public void testDefaultColumnValue() throws Exception { "test1 INTEGER, " + "CONSTRAINT NAME_PK PRIMARY KEY (pk1, pk2, pk3))"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); conn.createStatement().execute("ALTER TABLE " + sharedTable1 + " ADD test2 INTEGER DEFAULT 5, est3 INTEGER"); @@ -115,7 +116,7 @@ public void testDefaultColumnValueOnView() throws Exception { "test3 INTEGER, " + "CONSTRAINT NAME_PK PRIMARY KEY (pk1, pk2, pk3))"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); conn.createStatement().execute("CREATE VIEW " + sharedTable2 + "(pk4 INTEGER NOT NULL DEFAULT 20 PRIMARY KEY, test4 VARCHAR DEFAULT 'foo') " + @@ -148,7 +149,7 @@ public void testDefaultColumnValueProjected() throws Exception { "test3 INTEGER, " + "CONSTRAINT NAME_PK PRIMARY KEY (pk1, pk2, pk3))"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); String dml = "UPSERT INTO " + sharedTable1 + " VALUES (1, 2)"; @@ -225,7 +226,7 @@ public void testMultipleDefaults() throws Exception { "test4 INTEGER, " + "CONSTRAINT NAME_PK PRIMARY KEY (pk1, pk2, pk3))"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); String dml = "UPSERT INTO " + table + " VALUES (1)"; @@ -276,7 +277,7 @@ public void testDefaultImmutableRows() throws Exception { "CONSTRAINT NAME_PK PRIMARY KEY (pk1, pk2, pk3))" + "IMMUTABLE_ROWS=true"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); String dml = "UPSERT INTO " + table + " VALUES (1)"; @@ -321,7 +322,7 @@ public void testTrailingNullOverwritingDefault() throws Exception { "mid INTEGER, " + "def INTEGER DEFAULT 10)"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); String dml = "UPSERT INTO " + table + " VALUES (1, 10, null)"; @@ -349,7 +350,7 @@ public void testDefaultReinit() throws Exception { "test3 INTEGER, " + "CONSTRAINT NAME_PK PRIMARY KEY (pk1, pk2, pk3))"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); String dml = "UPSERT INTO " + sharedTable1 + " VALUES (1, 2)"; @@ -366,7 +367,7 @@ public void testDefaultReinit() throws Exception { assertFalse(rs.next()); conn.close(); - Connection conn2 = DriverManager.getConnection(getUrl()); + Connection conn2 = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); rs = conn2.createStatement() .executeQuery("SELECT pk3, test2 FROM " + sharedTable1 + " WHERE pk1 = 1"); @@ -386,7 +387,7 @@ public void testDefaultMiddlePrimaryKey() throws Exception { "test1 INTEGER, " + "CONSTRAINT NAME_PK PRIMARY KEY (pk1, pk2, pk3))"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); String dml = "UPSERT INTO " + table + " VALUES (1)"; @@ -444,7 +445,7 @@ public void testDefaultMiddleKeyValueCol() throws Exception { + "c2 INTEGER DEFAULT 50," + "c3 INTEGER)"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); String dml = "UPSERT INTO " + table + " VALUES (1)"; @@ -545,7 +546,7 @@ public void testDefaultAllDataTypesPrimaryKey() throws Exception { } private void testDefaultAllDataTypes(String table, String ddl) throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); String dml = "UPSERT INTO " + table + " VALUES (1)"; @@ -617,7 +618,7 @@ public void testDefaultExpressionPrimaryKey() throws Exception { } private void verifyDefaultExpression(String table, String ddl) throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); String dml = "UPSERT INTO " + table + " VALUES (1)"; @@ -639,7 +640,7 @@ private void verifyDefaultExpression(String table, String ddl) throws SQLExcepti @Test public void testDefaultUpsertSelectPrimaryKey() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String selectTable = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + selectTable + " (" + "pk INTEGER PRIMARY KEY)"; @@ -778,7 +779,7 @@ public void testDefaultArraysPrimaryKey() throws Exception { } private void verifyArrays(String table, String ddl) throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); String dml = "UPSERT INTO " + table + " VALUES (1)"; conn.createStatement().execute(dml); @@ -863,7 +864,7 @@ public void testDefaultArrayWithNull() throws Exception { + "c3 VARCHAR[5] DEFAULT ARRAY['ABCD', 'XY', NULL]" + ")"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); String dml = "UPSERT INTO " + table + " VALUES (1)"; conn.createStatement().execute(dml); @@ -889,7 +890,7 @@ public void testDefaultArrayWithFixedWidthNull() throws Exception { + "c3 INTEGER[5] DEFAULT ARRAY[1, 2, NULL]" + ")"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); String dml = "UPSERT INTO " + table + " VALUES (1)"; conn.createStatement().execute(dml); @@ -912,7 +913,7 @@ public void testDefaultNull() throws Exception { "pk INTEGER PRIMARY KEY, " + "def INTEGER DEFAULT NULL)"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); String dml = "UPSERT INTO " + table + " VALUES (1)"; @@ -936,7 +937,7 @@ public void testDefaultCoveredColumn() throws Exception { + "c1 INTEGER," + "c2 INTEGER DEFAULT 100)"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); conn.commit(); @@ -964,7 +965,7 @@ public void testDefaultIndexed() throws Exception { + "c1 INTEGER," + "c2 INTEGER DEFAULT 100)"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); conn.commit(); @@ -995,7 +996,7 @@ public void testDefaultLocalIndexed() throws Exception { + "c1 INTEGER," + "c2 INTEGER DEFAULT 100)"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); conn.commit(); @@ -1026,7 +1027,7 @@ public void testDefaultFunctionalIndexed() throws Exception { + "c1 INTEGER," + "c2 INTEGER DEFAULT 100)"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); conn.commit(); @@ -1058,7 +1059,7 @@ public void testDefaultSelectWhere() throws Exception { + "c6 INTEGER DEFAULT \"MONTH\"(TO_TIMESTAMP('2015-6-05'))" + ")"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); String dml = "UPSERT INTO " + sharedTable2 + " VALUES (1)"; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DefaultPhoenixMultiViewListProviderIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DefaultPhoenixMultiViewListProviderIT.java index 1e69e3a0489..09227d600eb 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DefaultPhoenixMultiViewListProviderIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DefaultPhoenixMultiViewListProviderIT.java @@ -33,8 +33,8 @@ import static org.apache.phoenix.mapreduce.PhoenixTTLTool.DELETE_ALL_VIEWS; import static org.apache.phoenix.mapreduce.util.PhoenixConfigurationUtil.MAPREDUCE_MULTI_INPUT_QUERY_BATCH_SIZE; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; - /** * Disabling this test as this works on TTL being set on View which is removed and will be added in future. * TODO:- To enable this test after re-enabling TTL for view for more info check :- PHOENIX-6978 @@ -73,7 +73,7 @@ public void testGetPhoenixMultiViewList() throws Exception { String tenant2 = generateUniqueName(); DefaultPhoenixMultiViewListProvider defaultPhoenixMultiViewListProvider = new DefaultPhoenixMultiViewListProvider(); - Configuration cloneConfig = PropertiesUtil.cloneConfig(config); + Configuration cloneConfig = PropertiesUtil.cloneConfig(getConfiguration()); cloneConfig.set(PhoenixConfigurationUtil.MAPREDUCE_PHOENIX_TTL_DELETE_JOB_ALL_VIEWS, DELETE_ALL_VIEWS); @@ -93,11 +93,11 @@ GlobalView1 with TTL(1 ms) Index1 Index2 TenantView1, TenantView2 */ - try (Connection globalConn = DriverManager.getConnection(url); + try (Connection globalConn = DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenant1Connection = - PhoenixMultiInputUtil.buildTenantConnection(url, tenant1); + PhoenixMultiInputUtil.buildTenantConnection(PropertiesUtil.deepCopy(TEST_PROPERTIES), url, tenant1); Connection tenant2Connection = - PhoenixMultiInputUtil.buildTenantConnection(url, tenant2)) { + PhoenixMultiInputUtil.buildTenantConnection(PropertiesUtil.deepCopy(TEST_PROPERTIES), url, tenant2)) { globalConn.createStatement().execute(String.format(BASE_TABLE_DDL, baseTableFullName)); globalConn.createStatement().execute(String.format(VIEW_DDL_WITH_ID_PREFIX_AND_TTL, @@ -126,7 +126,7 @@ GlobalView1 with TTL(1 ms) GlobalView2 without TTL Index1 Index2 Index3 Index4 TenantView1, TenantView2 */ - try (Connection globalConn = DriverManager.getConnection(url)) { + try (Connection globalConn = DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES));) { globalConn.createStatement().execute(String.format(VIEW_DDL, globalViewName2, baseTableFullName)); globalConn.createStatement().execute( @@ -146,9 +146,9 @@ GlobalView1 with TTL(1 ms) GlobalView2 without TTL */ try (Connection tenant1Connection = - PhoenixMultiInputUtil.buildTenantConnection(url, tenant1); + PhoenixMultiInputUtil.buildTenantConnection(PropertiesUtil.deepCopy(TEST_PROPERTIES), url, tenant1); Connection tenant2Connection = - PhoenixMultiInputUtil.buildTenantConnection(url, tenant2)) { + PhoenixMultiInputUtil.buildTenantConnection(PropertiesUtil.deepCopy(TEST_PROPERTIES), url, tenant2)) { tenant1Connection.createStatement().execute( String.format(TENANT_VIEW_DDL_WITH_TTL,tenantViewName3, globalViewName2)); tenant2Connection.createStatement().execute( @@ -161,7 +161,7 @@ GlobalView1 with TTL(1 ms) GlobalView2 without TTL Testing tenant specific case. Even tenant1 created 2 leaf views, one of them was created under a global view with TTL. This will not add to the deletion list. */ - cloneConfig = PropertiesUtil.cloneConfig(config); + cloneConfig = PropertiesUtil.cloneConfig(getConfiguration()); cloneConfig.set(MAPREDUCE_MULTI_INPUT_QUERY_BATCH_SIZE,"2"); cloneConfig.set(PhoenixConfigurationUtil.MAPREDUCE_TENANT_ID, tenant1); result = defaultPhoenixMultiViewListProvider.getPhoenixMultiViewList(cloneConfig); @@ -181,7 +181,7 @@ GlobalView1 with TTL(1 ms) GlobalView2 without TTL Without tenant id, it will not add the job to the list even the tenant view name is provided. */ - cloneConfig = PropertiesUtil.cloneConfig(config); + cloneConfig = PropertiesUtil.cloneConfig(getConfiguration()); cloneConfig.set(MAPREDUCE_MULTI_INPUT_QUERY_BATCH_SIZE,"2"); cloneConfig.set(PhoenixConfigurationUtil.MAPREDUCE_PHOENIX_TTL_DELETE_JOB_PER_VIEW, tenantViewName3); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java index bfd96df678d..f4ded4af195 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DeleteIT.java @@ -55,7 +55,7 @@ import org.apache.phoenix.compile.DeleteCompiler; import org.apache.phoenix.compile.MutationPlan; import org.apache.phoenix.end2end.index.IndexTestUtil; -import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixStatement; import org.apache.phoenix.parse.DeleteStatement; import org.apache.phoenix.parse.SQLParser; @@ -68,7 +68,6 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; - @Category(ParallelStatsDisabledTest.class) @RunWith(Parameterized.class) public class DeleteIT extends ParallelStatsDisabledIT { @@ -115,7 +114,7 @@ public void testDeleteFilterAutoCommit() throws Exception { } private void testDeleteFilter(boolean autoCommit) throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_DELETE_MUTATIONS, allowServerSideMutations); Connection conn = DriverManager.getConnection(getUrl(), props); @@ -145,7 +144,7 @@ public void testDeleteByRowAndFilterNoAutoCommit() throws SQLException { } private void testDeleteByFilterAndRow(boolean autoCommit) throws SQLException { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_DELETE_MUTATIONS, allowServerSideMutations); Connection conn = DriverManager.getConnection(getUrl(), props); @@ -213,7 +212,7 @@ private void testDeleteRange(boolean autoCommit, boolean createIndex) throws Exc } private void testDeleteRange(boolean autoCommit, boolean createIndex, boolean local) throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_DELETE_MUTATIONS, allowServerSideMutations); Connection conn = DriverManager.getConnection(getUrl(), props); @@ -347,7 +346,7 @@ private void testDeleteAllFromTableWithIndex(boolean autoCommit, boolean isSalte private void testDeleteAllFromTableWithIndex(boolean autoCommit, boolean isSalted, boolean localIndex) throws Exception { Connection con = null; try { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_DELETE_MUTATIONS, allowServerSideMutations); con = DriverManager.getConnection(getUrl(), props); @@ -442,7 +441,7 @@ public void testPointDeleteRowFromTableWithImmutableIndex(boolean localIndex, bo Connection con = null; try { boolean autoCommit = false; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_DELETE_MUTATIONS, allowServerSideMutations); con = DriverManager.getConnection(getUrl(), props); @@ -520,7 +519,7 @@ public void testDeleteRowFromTableWithImmutableIndex(boolean localIndex, boolean Connection con = null; try { boolean autoCommit = false; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_DELETE_MUTATIONS, allowServerSideMutations); con = DriverManager.getConnection(getUrl(), props); @@ -646,7 +645,7 @@ public void testDeleteAllFromTableAutoCommit() throws SQLException { private void testDeleteAllFromTable(boolean autoCommit) throws SQLException { Connection con = null; try { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_DELETE_MUTATIONS, allowServerSideMutations); con = DriverManager.getConnection(getUrl(), props); @@ -710,7 +709,7 @@ public void testDeleteForTableWithRowTimestampColClient() throws Exception { } private void testDeleteForTableWithRowTimestampCol(boolean autoCommit, String tableName) throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_DELETE_MUTATIONS, allowServerSideMutations); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { @@ -797,7 +796,7 @@ private void testPointDeleteWithMultipleImmutableIndexes(boolean alterTable) thr + "CREATE INDEX IF NOT EXISTS index_column_varchar_id ON " + tableName + "(varchar_id);" + "CREATE INDEX IF NOT EXISTS index_column_double_id ON " + tableName + "(double_id);" + "UPSERT INTO " + tableName + " VALUES (9000000,0.5,'Sample text extra');" ; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_DELETE_MUTATIONS, allowServerSideMutations); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { conn.setAutoCommit(true); @@ -821,7 +820,7 @@ private void testDeleteCount(boolean autoCommit, Integer limit) throws Exception String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " (pk1 DECIMAL NOT NULL, v1 VARCHAR CONSTRAINT PK PRIMARY KEY (pk1))"; int numRecords = 1010; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_DELETE_MUTATIONS, allowServerSideMutations); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { @@ -857,7 +856,7 @@ public void testClientSideDeleteShouldNotFailWhenSameColumnPresentInMultipleInde + " (pk1 DECIMAL NOT NULL, v1 VARCHAR, v2 VARCHAR CONSTRAINT PK PRIMARY KEY (pk1))"; String idx1 = "CREATE INDEX " + indexName1 + " ON " + tableName + "(v1)"; String idx2 = "CREATE INDEX " + indexName2 + " ON " + tableName + "(v1, v2)"; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_DELETE_MUTATIONS, allowServerSideMutations); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { @@ -1072,7 +1071,7 @@ private void createAndUpsertTable(String tableName, String indexName, Properties statement.execute(indexDdl1); } if (useOldCoproc) { - Admin admin = ((PhoenixConnection) conn).getQueryServices().getAdmin(); + Admin admin = ((PhoenixMonitoredConnection) conn).getQueryServices().getAdmin(); IndexTestUtil.downgradeCoprocs(tableName, indexName, admin); } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DerivedTableIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DerivedTableIT.java index b86b75cee15..62629be6cba 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DerivedTableIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DerivedTableIT.java @@ -61,7 +61,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; - @Category(ParallelStatsDisabledTest.class) @RunWith(Parameterized.class) public class DerivedTableIT extends ParallelStatsDisabledIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DescOrderKeysIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DescOrderKeysIT.java index 8fb2ee5cb34..3fd1888b0af 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DescOrderKeysIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DescOrderKeysIT.java @@ -26,18 +26,19 @@ import org.apache.phoenix.compile.QueryPlan; import org.apache.phoenix.jdbc.PhoenixStatement; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; @Category(ParallelStatsDisabledTest.class) public class DescOrderKeysIT extends ParallelStatsDisabledIT { @Test public void testVarCharDescOrderPKs() throws Exception { final String tableName = generateUniqueName(); - - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.setAutoCommit(true); final Statement stmt = conn.createStatement(); @@ -94,8 +95,7 @@ public void testVarCharDescOrderPKs() throws Exception { @Test public void testVarCharDescOrderMultiplePKs() throws Exception { final String tableName = generateUniqueName(); - - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.setAutoCommit(true); final Statement stmt = conn.createStatement(); @@ -181,8 +181,7 @@ public void testVarCharDescOrderMultiplePKs() throws Exception { @Test public void testIntDescOrderMultiplePKs() throws Exception { final String tableName = generateUniqueName(); - - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.setAutoCommit(true); final Statement stmt = conn.createStatement(); @@ -268,8 +267,7 @@ public void testIntDescOrderMultiplePKs() throws Exception { @Test public void testDoubleDescOrderMultiplePKs() throws Exception { final String tableName = generateUniqueName(); - - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.setAutoCommit(true); final Statement stmt = conn.createStatement(); @@ -356,7 +354,7 @@ public void testDoubleDescOrderMultiplePKs() throws Exception { public void testDecimalDescOrderMultiplePKs() throws Exception { final String tableName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.setAutoCommit(true); final Statement stmt = conn.createStatement(); @@ -445,7 +443,7 @@ public void testViewWithIntDescPkColumn() throws Exception { final String view01 = "v01_" + tableName; final String view02 = "v02_" + tableName; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + tableName @@ -562,7 +560,7 @@ public void testViewWithCharDescPkColumn() throws Exception { final String view01 = "v01_" + tableName; final String view02 = "v02_" + tableName; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + tableName @@ -763,7 +761,7 @@ public void testViewWithDoubleDescPkColumn() throws Exception { final String view01 = "v01_" + tableName; final String view02 = "v02_" + tableName; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + tableName @@ -966,7 +964,7 @@ public void testViewWithCharDescPkColumnAndViewIndex() throws Exception { final String index_view01 = "idx_v01_" + tableName; final String index_view02 = "idx_v02_" + tableName; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + tableName @@ -1159,7 +1157,7 @@ public void testViewWithTimestampDescPkColumnAndViewIndex() throws Exception { final String index_view01 = "idx_v01_" + tableName; final String index_view02 = "idx_v02_" + tableName; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + tableName diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DisableLocalIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DisableLocalIndexIT.java index a14fd059be4..937b894cb12 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DisableLocalIndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DisableLocalIndexIT.java @@ -31,7 +31,7 @@ import org.apache.hadoop.hbase.client.Table; import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.exception.SQLExceptionCode; -import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.util.MetaDataUtil; import org.apache.phoenix.util.PhoenixRuntime; @@ -39,7 +39,6 @@ import org.apache.phoenix.util.TestUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class DisableLocalIndexIT extends ParallelStatsDisabledIT { @@ -57,11 +56,11 @@ public void testDisabledLocalIndexes() throws Exception { conn.createStatement().execute("CREATE TABLE " + tableName + " (k1 VARCHAR NOT NULL, k2 VARCHAR, CONSTRAINT PK PRIMARY KEY(K1,K2)) MULTI_TENANT=true"); conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES('t1','x')"); conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES('t2','y')"); - Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin(); + Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin(); assertFalse(admin.tableExists(TableName.valueOf(MetaDataUtil.LOCAL_INDEX_TABLE_PREFIX + tableName))); admin.close(); try { - Table t = conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(Bytes.toBytes(MetaDataUtil.LOCAL_INDEX_TABLE_PREFIX + tableName)); + Table t = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getTable(Bytes.toBytes(MetaDataUtil.LOCAL_INDEX_TABLE_PREFIX + tableName)); t.getDescriptor(); // Exception no longer thrown by getTable, but instead need to force an RPC fail("Local index table should not have been created"); } catch (org.apache.hadoop.hbase.TableNotFoundException e) { @@ -77,7 +76,7 @@ public void testDisabledLocalIndexes() throws Exception { tsconn.createStatement().execute("CREATE VIEW " + viewName + "(V1 VARCHAR) AS SELECT * FROM " + tableName); tsconn.createStatement().execute("CREATE INDEX " + indexName1 + " ON " + viewName + "(V1)"); - tsconn.unwrap(PhoenixConnection.class).getQueryServices().getTable(Bytes.toBytes(MetaDataUtil.VIEW_INDEX_TABLE_PREFIX + tableName)); + tsconn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getTable(Bytes.toBytes(MetaDataUtil.VIEW_INDEX_TABLE_PREFIX + tableName)); try { conn.createStatement().execute("CREATE LOCAL INDEX " + indexName2 + " ON " + tableName + "(k2)"); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DistinctCountIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DistinctCountIT.java index 9463d041c8f..f68c3209afc 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DistinctCountIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DistinctCountIT.java @@ -50,7 +50,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class DistinctCountIT extends ParallelStatsDisabledIT { @@ -273,7 +272,7 @@ protected static void initATableValues(String tenantId1, String tenantId2, byte[ String tableName) throws Exception { ensureTableCreated(getUrl(), tableName, ATABLE_NAME, splits, null); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); try { // Insert all rows at ts diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DistinctPrefixFilterIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DistinctPrefixFilterIT.java index 76a39a0a930..2f3c467c7d7 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DistinctPrefixFilterIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DistinctPrefixFilterIT.java @@ -35,7 +35,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class DistinctPrefixFilterIT extends ParallelStatsDisabledIT { private static final String PREFIX = "SERVER DISTINCT PREFIX"; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DropIndexedColsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DropIndexedColsIT.java index be020b267d1..8888c6c428f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DropIndexedColsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DropIndexedColsIT.java @@ -26,11 +26,13 @@ import java.util.Collection; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.schema.ColumnNotFoundException; import org.apache.phoenix.schema.PName; import org.apache.phoenix.schema.PNameFactory; import org.apache.phoenix.schema.PTable; import org.apache.phoenix.schema.PTableKey; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.SchemaUtil; import org.junit.Assert; import org.junit.Test; @@ -39,7 +41,7 @@ import org.junit.runners.Parameterized; import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB; - +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; @Category(NeedsOwnMiniClusterTest.class) @RunWith(Parameterized.class) public class DropIndexedColsIT extends SplitSystemCatalogIT { @@ -67,8 +69,8 @@ public static Collection data() { @Test public void testDropIndexedColsMultiTables() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); - Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL)) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tableWithView1 = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String tableWithView2 = SchemaUtil.getTableName(SCHEMA3, generateUniqueName()); @@ -156,7 +158,7 @@ public void testDropIndexedColsMultiTables() throws Exception { viewConn.commit(); // verify the index was created - PhoenixConnection pconn = viewConn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pconn = viewConn.unwrap(PhoenixMonitoredConnection.class); PName tenantId = PNameFactory.newName(TENANT1); PTable view = pconn.getTable(new PTableKey(tenantId, viewOfTable1)); PTable viewIndex = pconn.getTable(new PTableKey(tenantId, fullNameViewIndex1)); @@ -181,8 +183,8 @@ public void testDropIndexedColsMultiTables() throws Exception { @Test public void testDropIndexedColsSingleTable() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); - Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL)) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tableWithView = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String viewOfTable = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); String viewSchemaName = SchemaUtil.getSchemaNameFromFullName(viewOfTable); @@ -228,7 +230,7 @@ public void testDropIndexedColsSingleTable() throws Exception { viewConn.commit(); // verify the index was created - PhoenixConnection pconn = viewConn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pconn = viewConn.unwrap(PhoenixMonitoredConnection.class); PName tenantId = PNameFactory.newName(TENANT1); conn.createStatement().execute(ALTER_TABLE + tableWithView + " DROP COLUMN v2, v3, v5 "); // verify columns were dropped diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DropSchemaIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DropSchemaIT.java index f3340c91ae7..4307d618bea 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DropSchemaIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DropSchemaIT.java @@ -17,6 +17,8 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +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; @@ -34,10 +36,12 @@ import org.apache.hadoop.hbase.client.Admin; import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.BaseTest; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.SchemaNotFoundException; import org.apache.phoenix.util.ClientUtil; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; import org.junit.BeforeClass; @@ -48,7 +52,6 @@ import org.junit.runners.Parameterized.Parameters; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; - @Category(NeedsOwnMiniClusterTest.class) @RunWith(Parameterized.class) public class DropSchemaIT extends BaseTest { @@ -64,7 +67,11 @@ public static synchronized void doSetup() throws Exception { // Drop the HBase table metadata for this test props.put(QueryServices.DROP_METADATA_ATTRIB, Boolean.toString(true)); // Must update config before starting server - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @@ -76,12 +83,12 @@ public static synchronized Collection data() { @Test public void testDropSchema() throws Exception { String tableName = generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.toString(true)); String normalizeSchemaIdentifier = SchemaUtil.normalizeIdentifier(schema); String ddl = "DROP SCHEMA " + schema; try (Connection conn = DriverManager.getConnection(getUrl(), props); - Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { try { conn.createStatement().execute(ddl); fail(); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DropTableIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DropTableIT.java index 3c8c45bd0c6..0787e50c4a6 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DropTableIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DropTableIT.java @@ -17,15 +17,16 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertFalse; import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class DropTableIT extends ParallelStatsDisabledIT { @@ -33,8 +34,8 @@ public class DropTableIT extends ParallelStatsDisabledIT { public void testRepeatedDropTable() throws Exception { final String tableName = generateUniqueName(); final String url = getUrl(); - try (final Connection conn = DriverManager.getConnection(url); - final Statement stmt = conn.createStatement()) { + try (final Connection conn = DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES)); + final Statement stmt = conn.createStatement()) { assertFalse(stmt.execute(String.format("CREATE TABLE %s(pk varchar not null primary key)", tableName))); String dropTable = String.format("DROP TABLE IF EXISTS %s", tableName); for (int i = 0; i < 5; i++) { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DropTableWithViewsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DropTableWithViewsIT.java index da674be6b97..3913ae718d7 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DropTableWithViewsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DropTableWithViewsIT.java @@ -18,6 +18,7 @@ package org.apache.phoenix.end2end; import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertFalse; @@ -36,6 +37,7 @@ import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment; import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.TableViewFinderResult; import org.apache.phoenix.coprocessor.TaskRegionObserver; import org.apache.phoenix.util.ViewUtil; @@ -53,7 +55,6 @@ import org.junit.runners.Parameterized.Parameters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - @Category(NeedsOwnMiniClusterTest.class) @RunWith(Parameterized.class) public class DropTableWithViewsIT extends SplitSystemCatalogIT { @@ -116,9 +117,9 @@ private String generateDDL(String options, String format) { @Test public void testDropTableWithChildViews() throws Exception { String baseTable = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); - try (Connection conn = DriverManager.getConnection(getUrl()); - Connection viewConn = - isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1) : conn) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Connection viewConn = + isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES)) : conn) { conn.setAutoCommit(true); viewConn.setAutoCommit(true); // Empty the task table first. diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DynamicColumnIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DynamicColumnIT.java index a2df06060d4..8e256fbbef9 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DynamicColumnIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DynamicColumnIT.java @@ -39,7 +39,7 @@ import org.apache.hadoop.hbase.client.Table; import org.apache.hadoop.hbase.client.TableDescriptorBuilder; import org.apache.hadoop.hbase.util.Bytes; -import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.ConnectionQueryServices; import org.apache.phoenix.query.QueryConstants; import org.apache.phoenix.schema.ColumnAlreadyExistsException; @@ -57,7 +57,6 @@ * @since 1.3 */ - @Category(ParallelStatsDisabledTest.class) public class DynamicColumnIT extends ParallelStatsDisabledIT { private static final byte[] FAMILY_NAME_A = Bytes.toBytes(SchemaUtil.normalizeIdentifier("A")); @@ -68,7 +67,7 @@ public class DynamicColumnIT extends ParallelStatsDisabledIT { @Before public void initTable() throws Exception { tableName = generateUniqueName(); - try (PhoenixConnection pconn = DriverManager.getConnection(getUrl()).unwrap(PhoenixConnection.class)) { + try (PhoenixMonitoredConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixMonitoredConnection.class)) { ConnectionQueryServices services = pconn.getQueryServices(); try (Admin admin = services.getAdmin()) { TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(TableName.valueOf(tableName)); @@ -227,7 +226,7 @@ public void testDynamicColumnOnNewTable() throws Exception { " B.F2v1 varchar" + " CONSTRAINT pk PRIMARY KEY (entry))"; String dml = "UPSERT INTO " + tableName + " values (?, ?, ?, ?, ?)"; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES));) { conn.createStatement().execute(ddl); try (PreparedStatement stmt = conn.prepareStatement(dml)) { stmt.setString(1, "entry"); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DynamicColumnWildcardIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DynamicColumnWildcardIT.java index 446cc7eba09..0ec4e8de3f6 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DynamicColumnWildcardIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DynamicColumnWildcardIT.java @@ -21,14 +21,17 @@ import static java.sql.Types.BIGINT; import static java.sql.Types.INTEGER; import static java.sql.Types.VARCHAR; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_ENCODED_BYTES; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.IMMUTABLE_STORAGE_SCHEME; import static org.apache.phoenix.schema.PTable.ImmutableStorageScheme.ONE_CELL_PER_COLUMN; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; import org.apache.phoenix.query.BaseTest; import org.apache.phoenix.schema.PTable.ImmutableStorageScheme; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.junit.BeforeClass; import org.junit.Test; @@ -74,7 +77,11 @@ public DynamicColumnWildcardIT(boolean mutableTable, ImmutableStorageScheme stor public static synchronized void doSetup() throws Exception { Map clientProps = Maps.newHashMapWithExpectedSize(1); clientProps.put(WILDCARD_QUERY_DYNAMIC_COLS_ATTRIB, "true"); - setUpTestDriver(ReadOnlyProps.EMPTY_PROPS, new ReadOnlyProps(clientProps)); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(ReadOnlyProps.EMPTY_PROPS, new ReadOnlyProps(clientProps)); + } else { + setUpTestDriver(ReadOnlyProps.EMPTY_PROPS, new ReadOnlyProps(clientProps)); + } } // Create either a mutable table or an immutable table with the specified storage scheme @@ -94,7 +101,7 @@ private String generateTableCreateDDL(String tableName, String schema) { @Test // Test the case where the table DDL only contains 1 column which is the primary key public void testOnlySinglePkWithDynamicColumns() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.setAutoCommit(true); String tableName = generateUniqueName(); conn.createStatement().execute(generateTableCreateDDL(tableName, @@ -146,7 +153,7 @@ public void testOnlySinglePkWithDynamicColumns() throws SQLException { @Test // Test the case where the table DDL contains 1 primary key column and other columns as well public void testSinglePkAndOtherColsWithDynamicColumns() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.setAutoCommit(true); String tableName = generateUniqueName(); @@ -219,7 +226,7 @@ public void testSinglePkAndOtherColsWithDynamicColumns() throws SQLException { @Test // Test the case where the table DDL contains just the composite key and no other columns public void testCompositeKeyWithDynamicColumns() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.setAutoCommit(true); String tableName = generateUniqueName(); @@ -286,7 +293,7 @@ public void testCompositeKeyWithDynamicColumns() throws SQLException { @Test // Test the case where the table DDL contains the composite key and other columns public void testCompositeKeyAndOtherColsWithDynamicColumns() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.setAutoCommit(true); String tableName = generateUniqueName(); @@ -387,7 +394,7 @@ public void testCompositeKeyAndOtherColsWithDynamicColumns() throws SQLException @Test // Test if dynamic columns are properly exposed in column family wildcard queries public void testColumnFamilyWildcards() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.setAutoCommit(true); String tableName = generateUniqueName(); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DynamicFamilyIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DynamicFamilyIT.java index 7ebde4ab178..c81ab5ac514 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DynamicFamilyIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DynamicFamilyIT.java @@ -62,7 +62,6 @@ @edu.umd.cs.findbugs.annotations.SuppressWarnings( value="RV_RETURN_VALUE_IGNORED", justification="Designed to ignore.") - @Category(ParallelStatsDisabledTest.class) public class DynamicFamilyIT extends ParallelStatsDisabledIT { private static final String WEB_STATS = generateUniqueName(); @@ -110,7 +109,7 @@ public void doBeforeTestSetup() throws Exception { @SuppressWarnings("deprecation") private static void initTableValues() throws Exception { - ConnectionQueryServices services = driver.getConnectionQueryServices(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + ConnectionQueryServices services = driver.getConnectionQueryServices(getActiveUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Table hTable = services.getTable(SchemaUtil.getTableNameAsBytes(WEB_STATS_SCHEMA_NAME,WEB_STATS)); try { // Insert rows using standard HBase mechanism with standard HBase "types" @@ -331,6 +330,15 @@ public void testDynamicFamilyFunctionException() throws Exception { try { PreparedStatement statement = conn.prepareStatement(query); statement.executeQuery(); + } catch (Exception e) { + if (e instanceof SQLException) { + if (e.getCause() instanceof PhoenixParserException) { + //Expected in case of HA ENabled + throw (PhoenixParserException) e.getCause(); + } else { + throw e; + } + } } finally { conn.close(); } @@ -339,7 +347,7 @@ public void testDynamicFamilyFunctionException() throws Exception { @Test public void testSelectEntireColumnFamily() throws Exception { ResultSet rs; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.setAutoCommit(true); String tableName = generateUniqueName(); conn.createStatement().execute("CREATE TABLE " + tableName diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DynamicUpsertIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DynamicUpsertIT.java index a31ae5d1653..229dab68acc 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DynamicUpsertIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DynamicUpsertIT.java @@ -47,7 +47,6 @@ * @since 1.3 */ - @Category(ParallelStatsDisabledTest.class) public class DynamicUpsertIT extends ParallelStatsDisabledIT { private String tableName; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/EmptyColumnIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/EmptyColumnIT.java index 515e315c2f7..e8b09e40b43 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/EmptyColumnIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/EmptyColumnIT.java @@ -31,6 +31,7 @@ import static org.apache.phoenix.query.PhoenixTestBuilder.SchemaBuilder.TableOptions; import static org.apache.phoenix.query.PhoenixTestBuilder.SchemaBuilder.TenantViewOptions; import static org.apache.phoenix.query.PhoenixTestBuilder.SchemaBuilder.TenantViewIndexOptions; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import java.io.IOException; @@ -55,6 +56,7 @@ import org.apache.phoenix.query.PhoenixTestBuilder.BasicDataWriter; import org.apache.phoenix.schema.PTable; import org.apache.phoenix.util.IndexUtil; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.util.TestUtil; import org.junit.Ignore; @@ -85,7 +87,7 @@ private void assertAllHBaseRowsHaveEmptyColumnCell(byte[] hbaseTableName, byte[] emptyColumnFamilyName, byte[] emptyColumnName, long minTimestamp, int expectedRows) throws IOException, SQLException { - try (Table tbl = driver.getConnectionQueryServices(getUrl(), TestUtil.TEST_PROPERTIES) + try (Table tbl = driver.getConnectionQueryServices(getActiveUrl(), TEST_PROPERTIES) .getTable(hbaseTableName)) { Scan allRows = new Scan(); @@ -275,7 +277,7 @@ public void testWhenCustomTenantViewWithPKAndGlobalIndex() throws Exception { // Create a test data writer for the above schema. DataWriter dataWriter = new BasicDataWriter(); - try (Connection connection = DriverManager.getConnection(getUrl())) { + try (Connection connection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { connection.setAutoCommit(true); dataWriter.setConnection(connection); dataWriter.setDataSupplier(dataSupplier); @@ -322,7 +324,7 @@ public void testWhenCustomTenantViewWithPKAndGlobalIndex() throws Exception { // Create a test data writer for the above schema. DataWriter dataWriter = new BasicDataWriter(); - try (Connection connection = DriverManager.getConnection(getUrl())) { + try (Connection connection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { connection.setAutoCommit(true); dataWriter.setConnection(connection); dataWriter.setDataSupplier(dataSupplier); @@ -372,7 +374,7 @@ public void testWhenCustomTenantViewWithPKAndGlobalIndex() throws Exception { tenantConnectUrl = getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions() .getTenantId(); - try (Connection connection = DriverManager.getConnection(tenantConnectUrl)) { + try (Connection connection = DriverManager.getConnection(tenantConnectUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { connection.setAutoCommit(true); dataWriter.setConnection(connection); dataWriter.setDataSupplier(dataSupplier); @@ -437,7 +439,7 @@ public void testWhenCustomTenantViewWithPKAndGlobalIndex() throws Exception { // Create a test data writer for the above schema. DataWriter dataWriter = new BasicDataWriter(); - try (Connection connection = DriverManager.getConnection(getUrl())) { + try (Connection connection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { connection.setAutoCommit(true); dataWriter.setConnection(connection); dataWriter.setDataSupplier(dataSupplier); @@ -516,7 +518,7 @@ public void testWhenCustomTenantViewWithPKAndGlobalIndex() throws Exception { // Create a test data writer for the above schema. DataWriter dataWriter = new BasicDataWriter(); - try (Connection connection = DriverManager.getConnection(getUrl())) { + try (Connection connection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { connection.setAutoCommit(true); dataWriter.setConnection(connection); dataWriter.setDataSupplier(dataSupplier); @@ -611,7 +613,7 @@ public void testWhenCustomTenantViewWithPKAndGlobalIndex() throws Exception { tenantConnectUrl = getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions() .getTenantId(); - try (Connection connection = DriverManager.getConnection(tenantConnectUrl)) { + try (Connection connection = DriverManager.getConnection(tenantConnectUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { connection.setAutoCommit(true); dataWriter.setConnection(connection); dataWriter.setDataSupplier(dataSupplier); @@ -723,7 +725,7 @@ public void testWhenCustomTenantViewWithIndexAndVariousOptions() throws Exceptio getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder .getDataOptions().getTenantId(); try (Connection connection = DriverManager - .getConnection(tenantConnectUrl)) { + .getConnection(tenantConnectUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { connection.setAutoCommit(true); dataWriter.setConnection(connection); dataWriter.setDataSupplier(dataSupplier); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/EncodeBinaryFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/EncodeBinaryFunctionIT.java index 010ec126353..c9cb4b39ee9 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/EncodeBinaryFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/EncodeBinaryFunctionIT.java @@ -16,6 +16,7 @@ */ package org.apache.phoenix.end2end; +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; @@ -29,11 +30,11 @@ import java.util.Arrays; import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class EncodeBinaryFunctionIT extends ParallelStatsDisabledIT { @@ -45,7 +46,7 @@ public class EncodeBinaryFunctionIT extends ParallelStatsDisabledIT { @BeforeClass public static void setUpBeforeClass() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); testTable = generateUniqueName(); String ddl = "CREATE TABLE " + testTable + " (id INTEGER PRIMARY KEY, data VARBINARY)"; conn.createStatement().execute(ddl); @@ -63,7 +64,7 @@ public static void setUpBeforeClass() throws Exception { @Test public void testEncodeHex() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement() .executeQuery("SELECT ENCODE_BINARY(data, 'HEX') FROM " + testTable + " WHERE ID=2"); @@ -75,7 +76,7 @@ public void testEncodeHex() throws Exception { @Test public void testMixedCaseHexDecoding() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement() .executeQuery("SELECT ENCODE_BINARY(data, 'HEX') FROM " + testTable + " WHERE ID=2"); @@ -87,7 +88,7 @@ public void testMixedCaseHexDecoding() throws Exception { @Test public void testEncodeBase64() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement() .executeQuery("SELECT ENCODE_BINARY(data, 'BASE64') FROM " + testTable + " WHERE ID=1"); @@ -99,7 +100,7 @@ public void testEncodeBase64() throws Exception { @Test public void testLongBase64Decoding() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); StringBuilder base64String = new StringBuilder(); for (int i = 0; i < 20; i++) { @@ -127,7 +128,7 @@ public void testLongBase64Decoding() throws Exception { @Test public void testEncodeHBase() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement() .executeQuery("SELECT ENCODE_BINARY(data, 'HBASE') FROM " + testTable + " WHERE ID=1"); @@ -139,7 +140,7 @@ public void testEncodeHBase() throws Exception { @Test public void testInvalidDecodingFormat() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { conn.createStatement().executeQuery("SELECT ENCODE_BINARY(data, 'INVALIDFORMAT') FROM " + testTable); @@ -151,7 +152,7 @@ public void testInvalidDecodingFormat() throws Exception { @Test public void testNullAndEmptyStringDecoding() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement() .executeQuery("SELECT ENCODE_BINARY(data, 'HEX') FROM " + testTable + " WHERE ID=-10"); @@ -172,7 +173,7 @@ public void testNullAndEmptyStringDecoding() throws Exception { @Test public void testEncodeDecodeRoundHex() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery( "SELECT DECODE_BINARY(ENCODE_BINARY(data, 'HEX'), 'HEX') FROM " + testTable + " WHERE ID=1"); @@ -184,7 +185,7 @@ public void testEncodeDecodeRoundHex() throws Exception { @Test public void testEncodeDecodeRoundBase64() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery( "SELECT DECODE_BINARY(ENCODE_BINARY(data, 'BASE64'), 'BASE64') FROM " + testTable + " WHERE ID=1"); @@ -195,7 +196,7 @@ public void testEncodeDecodeRoundBase64() throws Exception { @Test public void testEncodeDecodeRoundHbase() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery( "SELECT DECODE_BINARY(ENCODE_BINARY(data, 'HBASE'), 'HBASE') FROM " + testTable + " WHERE ID=1"); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/EncodeFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/EncodeFunctionIT.java index 6d6095a05c0..8ce1e9f5d3b 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/EncodeFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/EncodeFunctionIT.java @@ -16,6 +16,7 @@ */ package org.apache.phoenix.end2end; +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; @@ -31,11 +32,11 @@ import java.util.List; import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.TestUtil; import org.junit.Test; import org.junit.experimental.categories.Category; import org.apache.phoenix.thirdparty.com.google.common.collect.Lists; - @Category(ParallelStatsDisabledTest.class) public class EncodeFunctionIT extends ParallelStatsDisabledIT { @@ -83,14 +84,14 @@ private void testEncode(Connection conn, List inputList, List ex @Test public void testEncode() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); testEncode(conn, Lists. newArrayList(Long.MAX_VALUE, 62, 10, 1, 0, -1, -10, -62, Long.MIN_VALUE), Lists.newArrayList("AzL8n0Y58m7", "10", "A", "1", "0", "-1", "-A", "-10", "-AzL8n0Y58m8")); } @Test public void testEncodeNullInput() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = TestUtil.initTables(conn, "BIGINT", Collections. singletonList(0l)); testEncodeHelper(conn, tableName, "kv", Collections. singletonList(null), "ASC"); testEncodeHelper(conn, tableName, "kv", Collections. singletonList(null), "DESC"); @@ -98,7 +99,7 @@ public void testEncodeNullInput() throws Exception { @Test public void testUpperCaseEncodingType() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + " ( pk VARCHAR(10) NOT NULL CONSTRAINT PK PRIMARY KEY (pk))"; @@ -115,7 +116,7 @@ public void testUpperCaseEncodingType() throws Exception { @Test public void testNullEncodingType() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + " ( pk VARCHAR(10) NOT NULL CONSTRAINT PK PRIMARY KEY (pk))"; conn.createStatement().execute(ddl); @@ -126,7 +127,7 @@ public void testNullEncodingType() throws Exception { @Test public void testNullValue() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + " ( pk VARCHAR(10) NOT NULL, val INTEGER CONSTRAINT PK PRIMARY KEY (pk))"; conn.createStatement().execute(ddl); @@ -145,7 +146,7 @@ public void testNullValue() throws Exception { @Test public void testUnsupportedEncodingType() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + " ( pk VARCHAR(10) NOT NULL CONSTRAINT PK PRIMARY KEY (pk))"; conn.createStatement().execute(ddl); @@ -160,7 +161,7 @@ public void testUnsupportedEncodingType() throws Exception { @Test public void testInvalidEncodingType() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + " ( some_column BINARY(12) NOT NULL CONSTRAINT PK PRIMARY KEY (some_column))"; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/EvaluationOfORIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/EvaluationOfORIT.java index e859b4e1451..b2b5eed4998 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/EvaluationOfORIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/EvaluationOfORIT.java @@ -33,7 +33,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class EvaluationOfORIT extends ParallelStatsDisabledIT{ diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExecuteStatementsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExecuteStatementsIT.java index db44fbc8e30..44e23a1bab9 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExecuteStatementsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExecuteStatementsIT.java @@ -24,6 +24,7 @@ import static org.apache.phoenix.util.TestUtil.ROW7; import static org.apache.phoenix.util.TestUtil.ROW8; import static org.apache.phoenix.util.TestUtil.ROW9; +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; @@ -43,10 +44,10 @@ import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.query.QueryConstants; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class ExecuteStatementsIT extends ParallelStatsDisabledIT { @@ -78,7 +79,7 @@ public void testExecuteStatements() throws Exception { " SELECT \"DATE\"+1, val*10, host FROM " + ptsdbTableName + ";"; Date now = new Date(System.currentTimeMillis()); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.setAutoCommit(true); List binds = Arrays.asList(6); int nStatements = PhoenixRuntime.executeStatements(conn, new StringReader(statements), binds); @@ -119,7 +120,7 @@ public void testExecuteStatements() throws Exception { @Test public void testCharPadding() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String rowKey = "hello"; String testString = "world"; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExpFunctionEnd2EndIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExpFunctionEnd2EndIT.java index 4c59ad4e363..adab5048d5a 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExpFunctionEnd2EndIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExpFunctionEnd2EndIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.apache.phoenix.util.TestUtil.closeStmtAndConn; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -28,6 +29,7 @@ import java.sql.ResultSet; import org.apache.phoenix.expression.function.ExpFunction; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -51,7 +53,7 @@ public void initTable() throws Exception { unsignedTableName = generateUniqueName(); try { - conn = DriverManager.getConnection(getUrl()); + conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String ddl; ddl = "CREATE TABLE " + signedTableName + " (k VARCHAR NOT NULL PRIMARY KEY, doub DOUBLE, fl FLOAT, inte INTEGER, lon BIGINT, smalli SMALLINT, tinyi TINYINT)"; conn.createStatement().execute(ddl); @@ -122,7 +124,7 @@ private void testUnsignedNumberSpec(Connection conn, double data) throws Excepti @Test public void testSignedNumber() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); for (double d : new double[] { 0.0, 1.0, 123.1234}) { testSignedNumberSpec(conn, d); } @@ -130,7 +132,7 @@ public void testSignedNumber() throws Exception { @Test public void testUnsignedNumber() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); for (double d : new double[] { 0.0, 1.0, 123.1234 }) { testUnsignedNumberSpec(conn, d); } @@ -138,7 +140,7 @@ public void testUnsignedNumber() throws Exception { @Test public void testExpForLeadingPK() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String ddl = "create table test (id integer primary key)"; conn.createStatement().execute(ddl); String dml = "upsert into test values (?)"; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsDisabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsDisabledIT.java index 3928f386eae..c4b2842a862 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsDisabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsDisabledIT.java @@ -18,6 +18,7 @@ package org.apache.phoenix.end2end; import static org.apache.phoenix.end2end.ExplainPlanWithStatsEnabledIT.getByteRowEstimates; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @@ -73,7 +74,7 @@ public void testBytesRowsForSelect() throws Exception { String sql = "SELECT * FROM " + tableA + " where k >= ?"; List binds = Lists.newArrayList(); binds.add(99); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { initData(conn, tableA); assertEstimatesAreNull(sql, binds, conn); } @@ -84,7 +85,7 @@ public void testBytesRowsForUnion() throws Exception { String tableA = generateUniqueName(); String tableB = generateUniqueName(); String sql = "SELECT * FROM " + tableA + " UNION ALL SELECT * FROM " + tableB; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { initData(conn, tableA); initData(conn, tableB); assertEstimatesAreNull(sql, Lists.newArrayList(), conn); @@ -98,7 +99,7 @@ public void testBytesRowsForHashJoin() throws Exception { String sql = "SELECT ta.c1.a, ta.c2.b FROM " + tableA + " ta JOIN " + tableB + " tb ON ta.k = tb.k"; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { initData(conn, tableA); initData(conn, tableB); assertEstimatesAreNull(sql, Lists.newArrayList(), conn); @@ -112,7 +113,7 @@ public void testBytesRowsForSortMergeJoin() throws Exception { String sql = "SELECT /*+ USE_SORT_MERGE_JOIN */ ta.c1.a, ta.c2.b FROM " + tableA + " ta JOIN " + tableB + " tb ON ta.k = tb.k"; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { initData(conn, tableA); initData(conn, tableB); assertEstimatesAreNull(sql, Lists.newArrayList(), conn); @@ -125,7 +126,7 @@ public void testBytesRowsForAggregateQuery() throws Exception { String sql = "SELECT count(*) FROM " + tableA + " where k >= ?"; List binds = Lists.newArrayList(); binds.add(99); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { initData(conn, tableA); assertEstimatesAreNull(sql, binds, conn); } @@ -136,7 +137,7 @@ public void testBytesRowsForUpsertSelectServerSide() throws Exception { String tableA = generateUniqueName(); String sql = "UPSERT INTO " + tableA + " SELECT * FROM " + tableA; List binds = Lists.newArrayList(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { initData(conn, tableA); conn.setAutoCommit(true); assertEstimatesAreNull(sql, binds, conn); @@ -148,7 +149,7 @@ public void testBytesRowsForUpsertSelectClientSide() throws Exception { String tableA = generateUniqueName(); String sql = "UPSERT INTO " + tableA + " SELECT * FROM " + tableA; List binds = Lists.newArrayList(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { initData(conn, tableA); conn.setAutoCommit(false); assertEstimatesAreNull(sql, binds, conn); @@ -163,7 +164,7 @@ public void testBytesRowsForUpsertValues() throws Exception { binds.add(99); binds.add(99); binds.add(99); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { initData(conn, tableA); assertEstimatesAreZero(sql, binds, conn); } @@ -175,7 +176,7 @@ public void testBytesRowsForDeleteServerSide() throws Exception { String sql = "DELETE FROM " + tableA + " where k >= ?"; List binds = Lists.newArrayList(); binds.add(99); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { initData(conn, tableA); conn.setAutoCommit(true); assertEstimatesAreNull(sql, binds, conn); @@ -188,7 +189,7 @@ public void testBytesRowsForDeleteClientSideExecutedSerially() throws Exception String sql = "DELETE FROM " + tableA + " where k >= ? LIMIT 2"; List binds = Lists.newArrayList(); binds.add(99); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { initData(conn, tableA); conn.setAutoCommit(false); Estimate info = getByteRowEstimates(conn, sql, binds); @@ -204,7 +205,7 @@ public void testBytesRowsForPointDelete() throws Exception { String sql = "DELETE FROM " + tableA + " where k = ?"; List binds = Lists.newArrayList(); binds.add(100); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { initData(conn, tableA); conn.setAutoCommit(false); assertEstimatesAreZero(sql, binds, conn); @@ -216,7 +217,7 @@ public void testBytesRowsForSelectExecutedSerially() throws Exception { String tableA = generateUniqueName(); String sql = "SELECT * FROM " + tableA + " LIMIT 2"; List binds = Lists.newArrayList(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { initData(conn, tableA); conn.setAutoCommit(false); Estimate info = getByteRowEstimates(conn, sql, binds); @@ -230,7 +231,7 @@ public void testBytesRowsForSelectExecutedSerially() throws Exception { public void testEstimatesForUnionWithTablesWithNullAndLargeGpWidth() throws Exception { String tableA = generateUniqueName(); String tableWithLargeGPWidth = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { initData(conn, tableA); // create a table with 1 MB guidepost width long guidePostWidth = 1000000; @@ -245,7 +246,7 @@ public void testEstimatesForUnionWithTablesWithNullAndLargeGpWidth() throws Exce conn.commit(); conn.createStatement().execute("UPDATE STATISTICS " + tableWithLargeGPWidth); } - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String sql = "SELECT * FROM " + tableA + " UNION ALL SELECT * FROM " + tableWithLargeGPWidth; assertEstimatesAreNull(sql, Lists.newArrayList(), conn); @@ -254,7 +255,7 @@ public void testEstimatesForUnionWithTablesWithNullAndLargeGpWidth() throws Exce @Test public void testDescTimestampAtBoundary() throws Exception { - Properties props = PropertiesUtil.deepCopy(new Properties()); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { conn.createStatement().execute( "CREATE TABLE FOO(\n" + " a VARCHAR NOT NULL,\n" @@ -273,7 +274,7 @@ public void testDescTimestampAtBoundary() throws Exception { @Test public void testUseOfRoundRobinIteratorSurfaced() throws Exception { - Properties props = PropertiesUtil.deepCopy(new Properties()); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.put(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, Boolean.toString(false)); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { String tableName = "testUseOfRoundRobinIteratorSurfaced".toUpperCase(); @@ -295,7 +296,7 @@ public void testUseOfRoundRobinIteratorSurfaced() throws Exception { @Test public void testRangeScanWithMetadataLookup() throws Exception { final String tableName = generateUniqueName(); - Properties props = PropertiesUtil.deepCopy(new Properties()); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { conn.createStatement().execute( "CREATE TABLE " + tableName + "(PK1 VARCHAR NOT NULL, " @@ -430,7 +431,7 @@ public void testMultiTenantWithMetadataLookup() throws Exception { final String view02 = generateUniqueName(); final String view03 = generateUniqueName(); final String view04 = generateUniqueName(); - Properties props = PropertiesUtil.deepCopy(new Properties()); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { conn.createStatement().execute( "CREATE TABLE " + tableName + "(TENANT_ID VARCHAR NOT NULL, " @@ -577,7 +578,7 @@ public void testMultiTenantWithMetadataLookup() throws Exception { } private Connection getTenantConnection(final String tenantId) throws Exception { - Properties tenantProps = new Properties(); + Properties tenantProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); return DriverManager.getConnection(getUrl(), tenantProps); } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java index 74c5fac1cd5..8a4353d4dff 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExplainPlanWithStatsEnabledIT.java @@ -19,6 +19,7 @@ import static org.apache.phoenix.query.QueryServicesOptions.DEFAULT_USE_STATS_FOR_PARALLELIZATION; import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB; +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.assertNull; @@ -36,6 +37,7 @@ import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixResultSet; import org.apache.phoenix.mapreduce.util.PhoenixConfigurationUtil; import org.apache.phoenix.schema.PTable; @@ -47,6 +49,7 @@ import org.apache.phoenix.util.EnvironmentEdge; import org.apache.phoenix.util.EnvironmentEdgeManager; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ScanUtil; import org.junit.BeforeClass; import org.junit.Test; @@ -80,7 +83,7 @@ public static synchronized void createTables() throws Exception { private static void createIndex(String indexName, String table, long guidePostWidth) throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute( "CREATE INDEX " + indexName + " ON " + table + " (c1.a) INCLUDE (c2.b) "); conn.createStatement().execute("UPDATE STATISTICS " + indexName); @@ -88,7 +91,7 @@ private static void createIndex(String indexName, String table, long guidePostWi } private static void initDataAndStats(String tableName, Long guidePostWidth) throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement() .execute("CREATE TABLE " + tableName + " (k INTEGER PRIMARY KEY, c1.a bigint, c2.b bigint)" @@ -110,7 +113,7 @@ private static void initDataAndStats(String tableName, Long guidePostWidth) thro private static Connection getTenantConnection(String tenantId) throws SQLException { String url = getUrl() + ';' + TENANT_ID_ATTRIB + '=' + tenantId; - return DriverManager.getConnection(url); + return DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES)); } @Test @@ -118,7 +121,7 @@ public void testBytesRowsForSelectWhenKeyOutOfRange() throws Exception { String sql = "SELECT * FROM " + tableA + " where k >= ?"; List binds = Lists.newArrayList(); binds.add(200); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { Estimate info = getByteRowEstimates(conn, sql, binds); assertEquals((Long) 0L, info.estimatedBytes); assertEquals((Long) 0L, info.estimatedRows); @@ -131,7 +134,7 @@ public void testBytesRowsForPointSelectWithLimitGreaterThanPointLookupSize() thr String sql = "SELECT * FROM " + tableA + " where k in (? ,?) limit 4"; List binds = Lists.newArrayList(); binds.add(103); binds.add(104); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { Estimate info = getByteRowEstimates(conn, sql, binds); assertEquals((Long) 200L, info.estimatedBytes); assertEquals((Long) 2L, info.estimatedRows); @@ -145,7 +148,7 @@ public void testBytesRowsForSelectWithLimit() throws Exception { String noIndexSQL = "SELECT /*+ NO_INDEX */ * FROM " + tableA + " where c1.a in (?,?) limit 3"; List binds = Lists.newArrayList(); binds.add(1); binds.add(2); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { Estimate info = getByteRowEstimates(conn, sql, binds); assertEquals((Long) 264L, info.estimatedBytes); assertEquals((Long) 3L, info.estimatedRows); @@ -162,7 +165,7 @@ public void testBytesRowsForSelectWithLimit() throws Exception { public void testBytesRowsForSelectWithLimitIgnored() throws Exception { String sql = "SELECT * FROM " + tableA + " where (c1.a > c2.b) limit 1"; List binds = Lists.newArrayList(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { ResultSet rs = conn.createStatement().executeQuery(sql); assertFalse(rs.next()); Estimate info = getByteRowEstimates(conn, sql, binds); @@ -178,7 +181,7 @@ public void testBytesRowsForSelectWhenKeyInRange() throws Exception { String sql = "SELECT * FROM " + tableB + " where k >= ?"; List binds = Lists.newArrayList(); binds.add(99); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { Estimate info = getByteRowEstimates(conn, sql, binds); assertEquals((Long) 634L, info.estimatedBytes); assertEquals((Long) 10L, info.estimatedRows); @@ -191,7 +194,7 @@ public void testBytesRowsForSelectOnIndex() throws Exception { String sql = "SELECT * FROM " + tableA + " where c1.a >= ?"; List binds = Lists.newArrayList(); binds.add(0); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { try (PreparedStatement statement = conn.prepareStatement(sql)) { int paramIdx = 1; for (Object bind : binds) { @@ -215,7 +218,7 @@ public void testBytesRowsForSelectOnIndex() throws Exception { public void testBytesRowsForUnion() throws Exception { String sql = "SELECT /*+ NO_INDEX */ * FROM " + tableA + " UNION ALL SELECT * FROM " + tableB; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { Estimate info = getByteRowEstimates(conn, sql, Lists.newArrayList()); assertEquals((Long) (2 * 634L), info.estimatedBytes); assertEquals((Long) (2 * 10L), info.estimatedRows); @@ -230,7 +233,7 @@ public void testEstimatesForUnionWithTableWithLargeGpWidth() throws Exception { String sql = "SELECT /*+ NO_INDEX */ * FROM " + tableA + " UNION ALL SELECT * FROM " + tableB + " UNION ALL SELECT * FROM " + tableWithLargeGPWidth; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { Estimate info = getByteRowEstimates(conn, sql, Lists.newArrayList()); assertEquals((Long) (2 * 634 + largeGpWidth), info.estimatedBytes); assertTrue(info.estimateInfoTs > 0); @@ -242,7 +245,7 @@ public void testBytesRowsForHashJoin() throws Exception { String sql = "SELECT ta.c1.a, ta.c2.b FROM " + tableA + " ta JOIN " + tableB + " tb ON ta.k = tb.k"; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { Estimate info = getByteRowEstimates(conn, sql, Lists.newArrayList()); assertEquals((Long) (634L), info.estimatedBytes); assertEquals((Long) (10L), info.estimatedRows); @@ -255,7 +258,7 @@ public void testBytesRowsForSortMergeJoin() throws Exception { String sql = "SELECT /*+ NO_INDEX USE_SORT_MERGE_JOIN */ ta.c1.a, ta.c2.b FROM " + tableA + " ta JOIN " + tableB + " tb ON ta.k = tb.k"; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { Estimate info = getByteRowEstimates(conn, sql, Lists.newArrayList()); assertEquals((Long) (2 * 634L), info.estimatedBytes); assertEquals((Long) (2 * 10L), info.estimatedRows); @@ -268,7 +271,7 @@ public void testBytesRowsForAggregateQuery() throws Exception { String sql = "SELECT count(*) FROM " + tableA + " where k >= ?"; List binds = Lists.newArrayList(); binds.add(99); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { Estimate info = getByteRowEstimates(conn, sql, binds); assertEquals((Long) 634L, info.estimatedBytes); assertEquals((Long) 10L, info.estimatedRows); @@ -280,7 +283,7 @@ public void testBytesRowsForAggregateQuery() throws Exception { public void testBytesRowsForUpsertSelectServerSide() throws Exception { String sql = "UPSERT INTO " + tableA + " SELECT * FROM " + tableB; List binds = Lists.newArrayList(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.setAutoCommit(true); Estimate info = getByteRowEstimates(conn, sql, binds); assertEquals((Long) 634L, info.estimatedBytes); @@ -293,7 +296,7 @@ public void testBytesRowsForUpsertSelectServerSide() throws Exception { public void testBytesRowsForUpsertSelectClientSide() throws Exception { String sql = "UPSERT INTO " + tableB + " SELECT * FROM " + tableB; List binds = Lists.newArrayList(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.setAutoCommit(false); Estimate info = getByteRowEstimates(conn, sql, binds); assertEquals((Long) 634L, info.estimatedBytes); @@ -309,7 +312,7 @@ public void testBytesRowsForUpsertValues() throws Exception { binds.add(99); binds.add(99); binds.add(99); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { Estimate info = getByteRowEstimates(conn, sql, binds); assertEquals((Long) 0L, info.estimatedBytes); assertEquals((Long) 0L, info.estimatedRows); @@ -322,7 +325,7 @@ public void testBytesRowsForDeleteServerSide() throws Exception { String sql = "DELETE FROM " + tableA + " where k >= ?"; List binds = Lists.newArrayList(); binds.add(99); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.setAutoCommit(true); Estimate info = getByteRowEstimates(conn, sql, binds); assertEquals((Long) 634L, info.estimatedBytes); @@ -336,7 +339,7 @@ public void testBytesRowsForDeleteClientSideExecutedSerially() throws Exception String sql = "DELETE FROM " + tableA + " where k >= ? LIMIT 2"; List binds = Lists.newArrayList(); binds.add(99); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.setAutoCommit(false); Estimate info = getByteRowEstimates(conn, sql, binds); assertEquals((Long) 200L, info.estimatedBytes); @@ -350,7 +353,7 @@ public void testBytesRowsForPointDelete() throws Exception { String sql = "DELETE FROM " + tableA + " where k = ?"; List binds = Lists.newArrayList(); binds.add(100); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.setAutoCommit(false); Estimate info = getByteRowEstimates(conn, sql, binds); assertEquals((Long) 0L, info.estimatedBytes); @@ -363,7 +366,7 @@ public void testBytesRowsForPointDelete() throws Exception { public void testBytesRowsForSelectExecutedSerially() throws Exception { String sql = "SELECT * FROM " + tableA + " LIMIT 2"; List binds = Lists.newArrayList(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.setAutoCommit(false); Estimate info = getByteRowEstimates(conn, sql, binds); assertEquals((Long) 176L, info.estimatedBytes); @@ -421,24 +424,24 @@ public static Estimate getByteRowEstimates(Connection conn, String sql, List= ?"; List binds = Lists.newArrayList(); binds.add("tenant0"); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { Estimate info = getByteRowEstimates(conn, sql, binds); assertEquals((Long) 681L, info.estimatedBytes); assertEquals((Long) 10L, info.estimatedRows); @@ -581,7 +584,7 @@ public void testBytesRowsForSelectOnTenantViews() throws Exception { */ binds.clear(); binds.add("tenant0"); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { sql = "SELECT * FROM " + multiTenantBaseTable + " WHERE ORGID >= ?"; Estimate info = getByteRowEstimates(conn, sql, binds); assertEquals((Long) 1167L, info.estimatedBytes); @@ -631,7 +634,7 @@ public void testBytesRowsForSelectOnTenantViews() throws Exception { @Test // See https://issues.apache.org/jira/browse/PHOENIX-4287 public void testEstimatesForAggregateQueries() throws Exception { String tableName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { int guidePostWidth = 20; String ddl = "CREATE TABLE " + tableName + " (k INTEGER PRIMARY KEY, a bigint, b bigint)" @@ -651,7 +654,7 @@ public void testEstimatesForAggregateQueries() throws Exception { conn.createStatement().execute("UPDATE STATISTICS " + tableName + ""); } List binds = Lists.newArrayList(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String sql = "SELECT COUNT(*) " + " FROM " + tableName; // We don't have the use stats for parallelization property // set on the table. In this case, we end up defaulting to the @@ -738,7 +741,7 @@ public void testSelectQueriesWithStatsForParallelizationOn() throws Exception { private void testSelectQueriesWithFilters(boolean useStatsForParallelization) throws Exception { String tableName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { int guidePostWidth = 20; String ddl = "CREATE TABLE " + tableName + " (k INTEGER PRIMARY KEY, a bigint, b bigint)" @@ -759,7 +762,7 @@ private void testSelectQueriesWithFilters(boolean useStatsForParallelization) th conn.createStatement().execute("UPDATE STATISTICS " + tableName + ""); } List binds = Lists.newArrayList(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { // query whose start key is before any data String sql = "SELECT a FROM " + tableName + " WHERE K >= 99"; ResultSet rs = conn.createStatement().executeQuery(sql); @@ -896,7 +899,7 @@ private static void createMultitenantTableAndViews(String tenant1View, String te // Use our own clock to get rows created with our controlled timestamp try { EnvironmentEdgeManager.injectEdge(clock); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { PreparedStatement stmt = conn.prepareStatement(ddl + " SPLIT ON (?,?,?,?)"); for (int i = 0; i < splits.length; i++) { stmt.setBytes(i+1, splits[i]); @@ -990,10 +993,10 @@ public void testPartialStatsForTenantViews() throws Exception { + " (orgId CHAR(15) NOT NULL, pk2 CHAR(3) NOT NULL, a bigint, b bigint CONSTRAINT PK PRIMARY KEY " + "(ORGID, PK2)) MULTI_TENANT=true, GUIDE_POSTS_WIDTH=20"; createTestTable(getUrl(), ddl, null, null); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { // split such that some data for view2 resides on region of view1 try (Admin admin = - conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { byte[] splitKey = Bytes.toBytes("00Dabcdetenant200B"); admin.split(TableName.valueOf(multiTenantTable), splitKey); } @@ -1030,7 +1033,7 @@ public void testPartialStatsForTenantViews() throws Exception { } String sql = ""; List binds = Lists.newArrayList(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { /* * I have seen compaction running and generating stats for the second region of * tenant2View So let's disable compaction on the table, delete any stats we have @@ -1044,7 +1047,7 @@ public void testPartialStatsForTenantViews() throws Exception { "DELETE FROM SYSTEM.STATS WHERE PHYSICAL_NAME = '" + multiTenantTable + "'"; conn.createStatement().executeUpdate(delete); conn.commit(); - conn.unwrap(PhoenixConnection.class).getQueryServices().clearCache(); + conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().clearCache(); } // Now let's run update stats on tenant1View try (Connection conn = getTenantConnection(tenantId1)) { @@ -1083,7 +1086,7 @@ public void testIndexesDontUseStatsIfOffForParentTable() throws Exception { private void testIndexesInheritUseStatsPropFromParentTable(boolean useStats) throws Exception { String baseTable = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String ddl = "CREATE TABLE " + baseTable + " (k INTEGER PRIMARY KEY, a bigint, b bigint, c bigint) GUIDE_POSTS_WIDTH=20, USE_STATS_FOR_PARALLELIZATION=" @@ -1205,7 +1208,7 @@ public void testQueryingWithUseStatsForParallelizationOnOff() throws SQLExceptio private void testUseStatsForParallelizationOnSaltedTable(boolean useStatsFlag, boolean salted) throws SQLException { String tableName = generateUniqueName(); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute( "create table " + tableName + "(k varchar not null primary key, v varchar) " + (salted ? " SALT_BUCKETS=2," : "") + " USE_STATS_FOR_PARALLELIZATION=" @@ -1236,7 +1239,7 @@ public void testUseStatsForParallelizationProperyOnViewIndex() throws SQLExcepti String tenantViewName = generateUniqueName(); String viewIndexName = generateUniqueName(); boolean useStats = !DEFAULT_USE_STATS_FOR_PARALLELIZATION; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement() .execute("create table " + tableName + "(tenantId CHAR(15) NOT NULL, pk1 integer NOT NULL, v varchar CONSTRAINT PK PRIMARY KEY " @@ -1257,11 +1260,11 @@ public void testUseStatsForParallelizationProperyOnViewIndex() throws SQLExcepti private void validatePropertyOnViewIndex(String viewName, String viewIndexName, boolean useStats, Connection conn, Connection tenantConn) throws SQLException, TableNotFoundException { // fetch the latest view ptable - tenantConn.unwrap(PhoenixConnection.class).getTableNoCache(viewName); - PhoenixConnection phxConn = conn.unwrap(PhoenixConnection.class); + tenantConn.unwrap(PhoenixMonitoredConnection.class).getTableNoCache(viewName); + PhoenixMonitoredConnection phxConn = conn.unwrap(PhoenixMonitoredConnection.class); PTable viewIndex = phxConn.getTable(new PTableKey(phxConn.getTenantId(), viewIndexName)); assertEquals("USE_STATS_FOR_PARALLELIZATION property set incorrectly", useStats, - ScanUtil.getStatsForParallelizationProp(tenantConn.unwrap(PhoenixConnection.class), viewIndex)); + ScanUtil.getStatsForParallelizationProp(tenantConn.unwrap(PhoenixMonitoredConnection.class), viewIndex)); } } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExtendedQueryExecIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExtendedQueryExecIT.java index 9add3a31238..5a6fde3471c 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExtendedQueryExecIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExtendedQueryExecIT.java @@ -40,7 +40,6 @@ * Extended tests for Phoenix JDBC implementation * */ - @Category(ParallelStatsDisabledTest.class) public class ExtendedQueryExecIT extends ParallelStatsDisabledIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/FirstValueFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/FirstValueFunctionIT.java index 78a616f1606..16b787f357b 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/FirstValueFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/FirstValueFunctionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +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; @@ -25,16 +26,15 @@ import java.sql.DriverManager; import java.sql.ResultSet; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class FirstValueFunctionIT extends ParallelStatsDisabledIT { @Test public void signedLongAsBigInt() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); - + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " + "(id INTEGER NOT NULL PRIMARY KEY, page_id UNSIGNED_LONG," @@ -64,8 +64,7 @@ public void signedLongAsBigInt() throws Exception { @Test public void testSortOrderInSortCol() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); - + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " + "(id INTEGER NOT NULL, page_id UNSIGNED_LONG," @@ -95,8 +94,7 @@ public void testSortOrderInSortCol() throws Exception { @Test public void testSortOrderInDataCol() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); - + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " + "(id INTEGER NOT NULL, page_id UNSIGNED_LONG," @@ -126,8 +124,7 @@ public void testSortOrderInDataCol() throws Exception { @Test public void doubleDataType() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); - + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " + "(id INTEGER NOT NULL PRIMARY KEY, page_id UNSIGNED_LONG, " @@ -157,8 +154,7 @@ public void doubleDataType() throws Exception { @Test public void varcharFixedLenghtDatatype() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); - + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String table_name = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + table_name + " " + "(id INTEGER NOT NULL PRIMARY KEY, page_id UNSIGNED_LONG, " @@ -188,8 +184,7 @@ public void varcharFixedLenghtDatatype() throws Exception { @Test public void floatDataType() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); - + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " + "(id INTEGER NOT NULL PRIMARY KEY, page_id UNSIGNED_LONG," @@ -220,7 +215,7 @@ public void floatDataType() throws Exception { @Test public void allColumnsNull() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/FirstValuesFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/FirstValuesFunctionIT.java index 2ebd46e2597..60fa846bdbe 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/FirstValuesFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/FirstValuesFunctionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +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; @@ -26,11 +27,11 @@ import java.sql.ResultSet; import java.util.ArrayList; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class FirstValuesFunctionIT extends ParallelStatsDisabledIT { @@ -75,8 +76,7 @@ public void simpleTest() throws Exception { @Test public void varcharDatatypeSimpleTest() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); - + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String table_name = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + table_name + " " + "(id INTEGER NOT NULL PRIMARY KEY, page_id UNSIGNED_LONG, " @@ -106,8 +106,7 @@ public void varcharDatatypeSimpleTest() throws Exception { //@Test public void floatDatatypeSimpleTest() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); - + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " + "(id INTEGER NOT NULL PRIMARY KEY, page_id UNSIGNED_LONG," @@ -138,8 +137,7 @@ public void floatDatatypeSimpleTest() throws Exception { //@Test public void doubleDatatypeSimpleTest() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); - + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " + "(id INTEGER NOT NULL PRIMARY KEY, page_id UNSIGNED_LONG, " @@ -170,8 +168,7 @@ public void doubleDatatypeSimpleTest() throws Exception { //@Test public void offsetValueAscOrder() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); - + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " @@ -204,8 +201,7 @@ public void offsetValueAscOrder() throws Exception { //@Test public void simpleTestNoGroupBy() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); - + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " + "(id INTEGER NOT NULL PRIMARY KEY, page_id UNSIGNED_LONG," @@ -228,8 +224,7 @@ public void simpleTestNoGroupBy() throws Exception { //@Test public void rowLessThanOffsetNoGroupBy() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); - + Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " + "(id INTEGER NOT NULL PRIMARY KEY, page_id UNSIGNED_LONG," @@ -252,8 +247,7 @@ public void rowLessThanOffsetNoGroupBy() throws Exception { //@Test public void offsetValueDescOrder() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); - + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " + "(id INTEGER NOT NULL PRIMARY KEY, page_id UNSIGNED_LONG," @@ -285,7 +279,7 @@ public void offsetValueDescOrder() throws Exception { //@Test public void offsetValueSubAggregation() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " @@ -319,7 +313,7 @@ public void offsetValueSubAggregation() throws Exception { //@Test public void offsetValueLastMismatchByColumn() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " @@ -352,7 +346,7 @@ public void offsetValueLastMismatchByColumn() throws Exception { //@Test public void testSortOrderInDataColWithOffset() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " @@ -383,7 +377,7 @@ public void testSortOrderInDataColWithOffset() throws Exception { //@Test public void nonUniqueValuesInOrderByAsc() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " @@ -418,7 +412,7 @@ public void nonUniqueValuesInOrderByAsc() throws Exception { //@Test public void nonUniqueValuesInOrderByAscSkipDuplicit() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " @@ -455,7 +449,7 @@ public void nonUniqueValuesInOrderByAscSkipDuplicit() throws Exception { //@Test public void nonUniqueValuesInOrderByDesc() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " @@ -490,7 +484,7 @@ public void nonUniqueValuesInOrderByDesc() throws Exception { //@Test public void nonUniqueValuesInOrderNextValueDesc() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " @@ -526,7 +520,7 @@ public void nonUniqueValuesInOrderNextValueDesc() throws Exception { //@Test public void nonUniqueValuesInOrderNextValueAsc() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " @@ -565,7 +559,7 @@ public void nonUniqueValuesInOrderNextValueAsc() throws Exception { //@Test public void ignoreNullValues() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " @@ -596,8 +590,7 @@ public void ignoreNullValues() throws Exception { //@Test public void rowLessThanOffsetWithGroupBy() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); - + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " + "(id INTEGER NOT NULL PRIMARY KEY, page_id UNSIGNED_LONG," diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/FlappingAlterTableIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/FlappingAlterTableIT.java index 7626cc833f9..13d137622fd 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/FlappingAlterTableIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/FlappingAlterTableIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.schema.LiteralTTLExpression.TTL_EXPRESSION_NOT_DEFINED; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; @@ -32,7 +33,7 @@ import org.apache.hadoop.hbase.client.ColumnFamilyDescriptor; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder; import org.apache.hadoop.hbase.client.TableDescriptor; -import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.LiteralTTLExpression; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; @@ -44,7 +45,6 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(NeedsOwnMiniClusterTest.class) public class FlappingAlterTableIT extends ParallelStatsDisabledIT { private String dataTableFullName; @@ -54,7 +54,11 @@ public static synchronized void doSetup() throws Exception { Map props = Maps.newHashMapWithExpectedSize(1); props.put(PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY, Integer.toString(60*60)); // An hour props.put(QueryServices.USE_STATS_FOR_PARALLELIZATION, Boolean.toString(false)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()), new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @Before @@ -81,7 +85,7 @@ public void testAddColumnForNewColumnFamily() throws Exception { conn1.createStatement().execute(ddl); TestUtil.assertTTLValue(conn1, dataTableFullName, TTL_EXPRESSION_NOT_DEFINED); - try (Admin admin = conn1.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn1.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { ColumnFamilyDescriptor[] columnFamilies = admin.getDescriptor(TableName.valueOf(dataTableFullName)).getColumnFamilies(); assertEquals(2, columnFamilies.length); assertEquals("0", columnFamilies[0].getNameAsString()); @@ -106,7 +110,7 @@ public void testNewColumnFamilyInheritsTTLOfEmptyCF() throws Exception { ddl = "ALTER TABLE " + dataTableFullName + " ADD CF.STRING VARCHAR"; conn1.createStatement().execute(ddl); TestUtil.assertTTLValue(conn1, dataTableFullName, new LiteralTTLExpression((1000))); - try (Admin admin = conn1.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn1.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { TableDescriptor tableDesc = admin.getDescriptor(TableName.valueOf(dataTableFullName)); ColumnFamilyDescriptor[] columnFamilies = tableDesc.getColumnFamilies(); assertEquals(2, columnFamilies.length); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/FlappingLocalIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/FlappingLocalIndexIT.java index 570eeb3b3b5..a70eb4b31e9 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/FlappingLocalIndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/FlappingLocalIndexIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +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.assertNull; @@ -50,13 +51,13 @@ import org.apache.phoenix.query.QueryConstants; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.query.QueryServicesOptions; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.QueryUtil; import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.util.TestUtil; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - public class FlappingLocalIndexIT extends BaseLocalIndexIT { private static final Logger LOGGER = LoggerFactory.getLogger(FlappingLocalIndexIT.class); @@ -71,7 +72,7 @@ public void testScanWhenATableHasMultipleLocalIndexes() throws Exception { String indexName = "IDX_" + generateUniqueName(); createBaseTable(tableName, null, "('e','i','o')"); - Connection conn1 = DriverManager.getConnection(getUrl()); + Connection conn1 = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { conn1.createStatement().execute("UPSERT INTO " + tableName + " values('b',1,2,4,'z')"); conn1.createStatement().execute("UPSERT INTO " + tableName + " values('f',1,2,3,'a')"); @@ -81,7 +82,7 @@ public void testScanWhenATableHasMultipleLocalIndexes() throws Exception { conn1.createStatement().execute("CREATE LOCAL INDEX " + indexName + " ON " + tableName + "(v1)"); conn1.createStatement().execute("CREATE LOCAL INDEX " + indexName + "2 ON " + tableName + "(k3)"); conn1.commit(); - conn1 = DriverManager.getConnection(getUrl()); + conn1 = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn1.createStatement().executeQuery("SELECT COUNT(*) FROM " + tableName); assertTrue(rs.next()); assertEquals(4, rs.getInt(1)); @@ -96,7 +97,7 @@ public void testLocalIndexScanWithSmallChunks() throws Exception { String indexName = "IDX_" + generateUniqueName(); createBaseTable(tableName, 3, null); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.SCAN_RESULT_CHUNK_SIZE, "2"); props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.toString(isNamespaceMapped)); Connection conn1 = DriverManager.getConnection(getUrl(), props); @@ -145,7 +146,7 @@ public void testLocalIndexScan() throws Exception { String indexPhysicalTableName = physicalTableName.getNameAsString(); createBaseTable(tableName, null, "('e','i','o')"); - Connection conn1 = DriverManager.getConnection(getUrl()); + Connection conn1 = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); try{ conn1.createStatement().execute("UPSERT INTO " + tableName + " values('a',1,2,5,'y')"); conn1.createStatement().execute("UPSERT INTO " + tableName + " values('b',1,2,4,'z')"); @@ -159,7 +160,7 @@ public void testLocalIndexScan() throws Exception { ResultSet rs = conn1.createStatement().executeQuery("SELECT COUNT(*) FROM " + indexTableName); assertTrue(rs.next()); - Admin admin = driver.getConnectionQueryServices(getUrl(), TestUtil.TEST_PROPERTIES).getAdmin(); + Admin admin = driver.getConnectionQueryServices(getActiveUrl(), TEST_PROPERTIES).getAdmin(); int numRegions = admin.getRegions(physicalTableName).size(); int trimmedRegionLocations = admin.getConfiguration() .getInt(QueryServices.MAX_REGION_LOCATIONS_SIZE_EXPLAIN_PLAN, -1); @@ -335,7 +336,7 @@ public void testBuildIndexWhenUserTableAlreadyHasData() throws Exception { String indexPhysicalTableName = physicalTableName.getNameAsString(); createBaseTable(tableName, null, "('e','i','o')"); - Connection conn1 = DriverManager.getConnection(getUrl()); + Connection conn1 = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn1.createStatement().execute("UPSERT INTO "+tableName+" values('b',1,2,4,'z')"); conn1.createStatement().execute("UPSERT INTO "+tableName+" values('f',1,2,3,'z')"); conn1.createStatement().execute("UPSERT INTO "+tableName+" values('j',2,4,2,'a')"); @@ -345,7 +346,7 @@ public void testBuildIndexWhenUserTableAlreadyHasData() throws Exception { ResultSet rs = conn1.createStatement().executeQuery("SELECT COUNT(*) FROM " + indexTableName); assertTrue(rs.next()); assertEquals(4, rs.getInt(1)); - Admin admin = driver.getConnectionQueryServices(getUrl(), TestUtil.TEST_PROPERTIES).getAdmin(); + Admin admin = driver.getConnectionQueryServices(getActiveUrl(), TEST_PROPERTIES).getAdmin(); org.apache.hadoop.hbase.client.Connection hbaseConn = admin.getConnection(); Table indexTable = hbaseConn.getTable(TableName.valueOf(indexPhysicalTableName)); Pair startEndKeys = hbaseConn.getRegionLocator(TableName.valueOf(indexPhysicalTableName)).getStartEndKeys(); @@ -384,13 +385,13 @@ private void testBuildingLocalIndexShouldHandleNoSuchColumnFamilyException(boole TableName physicalTableName = SchemaUtil.getPhysicalTableName(tableName.getBytes(), isNamespaceMapped); createBaseTable(tableName, null, null, coveredIndex ? "cf" : null); - Connection conn1 = DriverManager.getConnection(getUrl()); + Connection conn1 = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn1.createStatement().execute("UPSERT INTO "+tableName+" values('b',1,2,4,'z')"); conn1.createStatement().execute("UPSERT INTO "+tableName+" values('f',1,2,3,'z')"); conn1.createStatement().execute("UPSERT INTO "+tableName+" values('j',2,4,2,'a')"); conn1.createStatement().execute("UPSERT INTO "+tableName+" values('q',3,1,1,'c')"); conn1.commit(); - Admin admin = driver.getConnectionQueryServices(getUrl(), TestUtil.TEST_PROPERTIES).getAdmin(); + Admin admin = driver.getConnectionQueryServices(getActiveUrl(), TEST_PROPERTIES).getAdmin(); TableDescriptor tableDescriptor = admin.getDescriptor(physicalTableName); tableDescriptor = TableDescriptorBuilder.newBuilder(tableDescriptor).setCoprocessor( CoprocessorDescriptorBuilder diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/FunkyNamesIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/FunkyNamesIT.java index 86bd6cfdaaf..2a431b36dcc 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/FunkyNamesIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/FunkyNamesIT.java @@ -35,7 +35,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class FunkyNamesIT extends ParallelStatsDisabledIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GetSetByteBitFunctionEnd2EndIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GetSetByteBitFunctionEnd2EndIT.java index 3590be30b15..1c92a039a4a 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GetSetByteBitFunctionEnd2EndIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GetSetByteBitFunctionEnd2EndIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.apache.phoenix.util.TestUtil.closeStmtAndConn; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; @@ -31,6 +32,7 @@ import org.apache.phoenix.expression.function.GetByteFunction; import org.apache.phoenix.expression.function.SetBitFunction; import org.apache.phoenix.expression.function.SetByteFunction; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -51,7 +53,7 @@ public void initTable() throws Exception { Connection conn = null; PreparedStatement stmt = null; try { - conn = DriverManager.getConnection(getUrl()); + conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String ddl; ddl = "CREATE TABLE " + TABLE_NAME + " (k VARCHAR NOT NULL PRIMARY KEY, b BINARY(4), vb VARBINARY)"; @@ -64,7 +66,7 @@ public void initTable() throws Exception { @Test public void test() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); PreparedStatement stmt = conn.prepareStatement( "UPSERT INTO " + TABLE_NAME + " VALUES (?, ?, ?)"); stmt.setString(1, KEY); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GlobalConnectionTenantTableIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GlobalConnectionTenantTableIT.java index dc04874e242..1c3de9714b8 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GlobalConnectionTenantTableIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GlobalConnectionTenantTableIT.java @@ -17,6 +17,8 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -30,17 +32,18 @@ import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.BaseTest; import org.apache.phoenix.schema.PTable; import org.apache.phoenix.util.EnvironmentEdgeManager; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; import org.junit.BeforeClass; import org.junit.Test; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; - //FIXME this class has no @Category, and is never run by maven public class GlobalConnectionTenantTableIT extends BaseTest { @@ -56,7 +59,11 @@ public class GlobalConnectionTenantTableIT extends BaseTest { @BeforeClass public static synchronized void doSetup() throws Exception { Map props = Maps.newHashMapWithExpectedSize(1); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()), new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } createBaseTable(SCHEMA_NAME, TABLE_NAME, true, null, null); try (Connection conn = getTenantConnection(TENANT_NAME)) { createView(conn, SCHEMA_NAME, VIEW_NAME, TABLE_NAME); @@ -66,7 +73,7 @@ public static synchronized void doSetup() throws Exception { @Test public void testGetLatestTenantTable() throws SQLException { - try (PhoenixConnection conn = (PhoenixConnection) getConnection()) { + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) getConnection()) { PTable table = conn.getTable(TENANT_NAME, FULL_VIEW_NAME, null); assertNotNull(table); table = null; @@ -78,7 +85,7 @@ public void testGetLatestTenantTable() throws SQLException { @Test public void testGetTenantViewAtTimestamp() throws SQLException { long startTime = EnvironmentEdgeManager.currentTimeMillis(); - try (PhoenixConnection conn = (PhoenixConnection) getConnection()) { + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) getConnection()) { PTable table = conn.getTable(TENANT_NAME, FULL_VIEW_NAME, null); long tableTimestamp = table.getTimeStamp(); // Alter table @@ -100,7 +107,7 @@ public void testGetTenantViewAtTimestamp() throws SQLException { @Test public void testGetTableWithoutTenantId() throws SQLException { - try (PhoenixConnection conn = (PhoenixConnection) getConnection()) { + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) getConnection()) { PTable table = conn.getTable(null, SchemaUtil.getTableName(SCHEMA_NAME, TABLE_NAME)); assertNotNull(table); @@ -117,7 +124,7 @@ public void testGetTableWithoutTenantId() throws SQLException { @Test public void testTableNotFound() throws SQLException { - try (PhoenixConnection conn = (PhoenixConnection) getConnection()) { + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) getConnection()) { try { PTable table = conn.getTable(TENANT_NAME, FULL_VIEW_NAME, 1L); fail("Expected TableNotFoundException"); @@ -130,7 +137,7 @@ public void testTableNotFound() throws SQLException { @Test public void testGetTableFromCache() throws SQLException { - try (PhoenixConnection conn = (PhoenixConnection) getConnection()) { + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) getConnection()) { PTable table = conn.getTable(TENANT_NAME, FULL_VIEW_NAME, null); PTable newTable = conn.getTable(TENANT_NAME, FULL_VIEW_NAME, null); assertNotNull(newTable); @@ -176,13 +183,13 @@ private static void createViewIndex(Connection conn, String schemaName, String i } private static Connection getTenantConnection(String tenant) throws SQLException { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenant); return DriverManager.getConnection(getUrl(), props); } private static Connection getConnection() throws SQLException { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); return DriverManager.getConnection(getUrl(), props); } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java index 7fa9329fad8..cd426d88f4c 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/GroupByIT.java @@ -51,7 +51,6 @@ import org.apache.phoenix.thirdparty.com.google.common.collect.Lists; - @Category(ParallelStatsDisabledTest.class) @RunWith(Parameterized.class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ImmutableTableIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ImmutableTableIT.java index 24d01ab7d9a..94185fafadc 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ImmutableTableIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ImmutableTableIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -25,8 +26,8 @@ import java.sql.ResultSet; import java.sql.Statement; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; - @Category(ParallelStatsDisabledTest.class) public class ImmutableTableIT extends ParallelStatsDisabledIT { @@ -35,8 +36,8 @@ public void testQueryWithMultipleColumnFamiliesAndSingleConditionForImmutableTab throws Exception { final String tn = generateUniqueName(); final String url = getUrl(); - try (Connection conn = DriverManager.getConnection(url); - Statement stmt = conn.createStatement()) { + try (Connection conn = DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Statement stmt = conn.createStatement()) { stmt.execute(String.format("CREATE TABLE %s (" + "ID VARCHAR PRIMARY KEY," + "COL1 VARCHAR," + @@ -70,7 +71,7 @@ public void testQueryWithMultipleColumnFamiliesAndMultipleConditionsForImmutable throws Exception { final String tn = generateUniqueName(); final String url = getUrl(); - try (Connection conn = DriverManager.getConnection(url); + try (Connection conn = DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.execute(String.format("CREATE TABLE %s (" + "ID VARCHAR PRIMARY KEY," + diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ImmutableTablePropertiesIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ImmutableTablePropertiesIT.java index 1e169b7b1fd..7b63941b453 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ImmutableTablePropertiesIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ImmutableTablePropertiesIT.java @@ -30,7 +30,7 @@ import java.util.Properties; import org.apache.phoenix.exception.SQLExceptionCode; -import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.schema.PTable; import org.apache.phoenix.schema.PTableKey; import org.apache.phoenix.util.PropertiesUtil; @@ -38,7 +38,6 @@ import org.junit.Ignore; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class ImmutableTablePropertiesIT extends ParallelStatsDisabledIT { @@ -61,7 +60,7 @@ public void testImmutableKeyword() throws Exception { " CONSTRAINT pk PRIMARY KEY (a_string)) STORE_NULLS=true"; stmt.execute(ddl); - PhoenixConnection phxConn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection phxConn = conn.unwrap(PhoenixMonitoredConnection.class); PTable immutableTable = phxConn.getTable(new PTableKey(null, immutableDataTableFullName)); assertTrue("IMMUTABLE_ROWS should be set to true", immutableTable.isImmutableRows()); PTable mutableTable = phxConn.getTable(new PTableKey(null, mutableDataTableFullName)); @@ -88,7 +87,7 @@ public void testImmutableProperty() throws Exception { " CONSTRAINT pk PRIMARY KEY (a_string)) IMMUTABLE_ROWS=false"; stmt.execute(ddl); - PhoenixConnection phxConn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection phxConn = conn.unwrap(PhoenixMonitoredConnection.class); PTable immutableTable = phxConn.getTable(new PTableKey(null, immutableDataTableFullName)); assertTrue("IMMUTABLE_ROWS should be set to true", immutableTable.isImmutableRows()); PTable mutableTable = phxConn.getTable(new PTableKey(null, mutableDataTableFullName)); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java index 04416fa2feb..9ab2484154f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/InListIT.java @@ -18,6 +18,7 @@ package org.apache.phoenix.end2end; import static java.util.Collections.singletonList; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.schema.PTable.ImmutableStorageScheme.ONE_CELL_PER_COLUMN; import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; @@ -98,7 +99,6 @@ import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; - @Category(ParallelStatsDisabledTest.class) @RunWith(Parameterized.class) public class InListIT extends ParallelStatsDisabledIT { @@ -200,8 +200,11 @@ public static synchronized Collection data() { @BeforeClass public static final void doSetup() throws Exception { - - setUpTestDriver(ReadOnlyProps.EMPTY_PROPS, ReadOnlyProps.EMPTY_PROPS); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(ReadOnlyProps.EMPTY_PROPS, ReadOnlyProps.EMPTY_PROPS); + } else { + setUpTestDriver(ReadOnlyProps.EMPTY_PROPS, ReadOnlyProps.EMPTY_PROPS); + } TENANT_SPECIFIC_URL1 = getUrl() + ';' + TENANT_ID_ATTRIB + "=tenant1"; TENANT_URL = getUrl() + ";" + PhoenixRuntime.TENANT_ID_ATTRIB + '=' + TENANT_ID; } @@ -381,8 +384,7 @@ private String getType(PDataType pkType) { } private static void createBaseTable(String baseTable) throws SQLException { - - try (Connection globalConnection = DriverManager.getConnection(getUrl())) { + try (Connection globalConnection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { try (Statement cstmt = globalConnection.createStatement()) { String CO_BASE_TBL_TEMPLATE = "CREATE TABLE IF NOT EXISTS %s(OID CHAR(15) NOT NULL,KP CHAR(3) NOT NULL,ROW_ID VARCHAR, COL1 VARCHAR,COL2 VARCHAR,COL3 VARCHAR,CREATED_DATE DATE,CREATED_BY CHAR(15),LAST_UPDATE DATE,LAST_UPDATE_BY CHAR(15),SYSTEM_MODSTAMP DATE CONSTRAINT pk PRIMARY KEY (OID,KP)) MULTI_TENANT=true,COLUMN_ENCODED_BYTES=0"; cstmt.execute(String.format(CO_BASE_TBL_TEMPLATE, baseTable)); @@ -394,7 +396,7 @@ private static void createBaseTable(String baseTable) throws SQLException { private void dropTenantViewData(int tenant, String tenantView) throws SQLException { String tenantConnectionUrl = String.format("%s;%s=%s%06d", getUrl(), TENANT_ID_ATTRIB, TENANT_PREFIX, tenant); - try (Connection tenantConnection = DriverManager.getConnection(tenantConnectionUrl)) { + try (Connection tenantConnection = DriverManager.getConnection(tenantConnectionUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { tenantConnection.setAutoCommit(true); try (Statement cstmt = tenantConnection.createStatement()) { cstmt.execute(String.format("DELETE FROM %s", tenantView)); @@ -414,7 +416,7 @@ private void createTenantView(int tenant, String baseTable, String tenantView, S createBaseTable(baseTable); String tenantConnectionUrl = String.format("%s;%s=%s%06d", getUrl(), TENANT_ID_ATTRIB, TENANT_PREFIX, tenant); - try (Connection tenantConnection = DriverManager.getConnection(tenantConnectionUrl)) { + try (Connection tenantConnection = DriverManager.getConnection(tenantConnectionUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { try (Statement cstmt = tenantConnection.createStatement()) { String TENANT_VIEW_TEMPLATE = "CREATE VIEW IF NOT EXISTS %s(ID1 %s not null,ID2 %s not null,ID3 %s not null,COL4 VARCHAR,COL5 VARCHAR,COL6 VARCHAR CONSTRAINT pk PRIMARY KEY (ID1 %s, ID2 %s, ID3 %s)) " + "AS SELECT * FROM %s WHERE KP = '%s'"; @@ -446,8 +448,8 @@ private void initializeTables() throws Exception { buildSchema(tableName, viewName1, true); buildSchema(tableName2, viewName2, false); for (boolean isMultiTenant : TENANCIES) { - Connection baseConn = DriverManager.getConnection(getUrl()); - Connection conn = isMultiTenant ? DriverManager.getConnection(TENANT_URL) : baseConn; + Connection baseConn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Connection conn = isMultiTenant ? DriverManager.getConnection(TENANT_URL, PropertiesUtil.deepCopy(TEST_PROPERTIES)) : baseConn; try { // test each combination of types and salting @@ -489,9 +491,8 @@ private void testWithIntegerTypesWithVariedSaltingAndTenancy(String whereClause, List expecteds) throws SQLException { // test single and multitenant tables for(boolean isMultiTenant : TENANCIES) { - Connection baseConn = DriverManager.getConnection(getUrl()); - Connection conn = isMultiTenant ? DriverManager.getConnection(TENANT_URL) - : baseConn; + Connection baseConn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Connection conn = isMultiTenant ? DriverManager.getConnection(TENANT_URL, PropertiesUtil.deepCopy(TEST_PROPERTIES)) : baseConn; try { // test each combination of types and salting @@ -804,7 +805,7 @@ private void testWithFixedLengthPK(SortOrder sortOrder) throws Exception { @Test public void testInListExpressionWithNull() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT COUNT(*) FROM SYSTEM.CATALOG WHERE " + "TENANT_ID IN ('', 'FOO')"); @@ -821,7 +822,7 @@ public void testInListExpressionWithNull() throws Exception { @Test public void testUpperWithInChar() throws Exception { String baseTable = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.execute("CREATE TABLE " + baseTable + " (ID BIGINT NOT NULL primary key, A CHAR(2))"); @@ -847,7 +848,7 @@ public void testUpperWithInChar() throws Exception { @Test public void testLowerWithInChar() throws Exception { String baseTable = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.execute("CREATE TABLE " + baseTable + " (ID BIGINT NOT NULL primary key, A CHAR(2))"); @@ -872,7 +873,7 @@ public void testLowerWithInChar() throws Exception { @Test(expected = TypeMismatchException.class) public void testInListExpressionWithNotValidElements() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT COUNT(*) FROM SYSTEM.CATALOG WHERE " + "TENANT_ID IN (4, 8)"); @@ -883,7 +884,7 @@ public void testInListExpressionWithNotValidElements() throws Exception { @Test(expected = SQLException.class) public void testInListExpressionWithNoElements() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT COUNT(*) FROM SYSTEM.CATALOG WHERE " + "TENANT_ID IN ()"); @@ -894,7 +895,7 @@ public void testInListExpressionWithNoElements() throws Exception { @Test public void testInListExpressionWithNullAndWrongTypedData() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT COUNT(*) FROM SYSTEM.CATALOG WHERE " + "TENANT_ID IN ('', 4)"); @@ -909,7 +910,7 @@ public void testInListExpressionWithDesc() throws Exception { String fullViewName = generateUniqueName(); String tenantView = generateUniqueName(); // create base table and global view using global connection - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + fullTableName + "(\n" + " TENANT_ID CHAR(15) NOT NULL,\n" + @@ -935,7 +936,7 @@ public void testInListExpressionWithDesc() throws Exception { } // create and use a tenant specific view to write data - try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1) ) { + try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES)) ) { Statement stmt = viewConn.createStatement(); stmt.execute("CREATE VIEW IF NOT EXISTS " + tenantView + " AS SELECT * FROM " + fullViewName ); viewConn.createStatement().execute("UPSERT INTO " + tenantView + "(CREATED_BY, CREATED_DATE, SYSTEM_MODSTAMP, MODEL, MILEAGE, MILES_DRIVEN, MAKE) VALUES ('005xx000001Sv6o', 1532458254819, 1532458254819, 'a5', 23, 10000, 'AUDI')"); @@ -972,7 +973,7 @@ public void testInListExpressionWithDesc() throws Exception { } private void buildSchema(String fullTableName, String fullViewName, boolean isDecOrder) throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.setAutoCommit(true); try (Statement stmt = conn.createStatement()) { stmt.execute("CREATE TABLE " + fullTableName + "(\n" + " TENANT_ID CHAR(15) NOT NULL,\n" + " KEY_PREFIX CHAR(3) NOT NULL, ID5 BIGINT \n" + @@ -981,7 +982,7 @@ private void buildSchema(String fullTableName, String fullViewName, boolean isDe stmt.execute("CREATE VIEW " + fullViewName + "(\n" + " ID1 VARCHAR NOT NULL,\n" + " ID2 VARCHAR NOT NULL,\n" + " ID3 BIGINT, ID4 BIGINT \n" + " CONSTRAINT PKVIEW PRIMARY KEY\n" + " (\n" + " ID1, ID2 DESC\n" + ")) " + "AS SELECT * FROM " + fullTableName + " WHERE KEY_PREFIX = '0CY'"); - try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1)) { + try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { viewConn.setAutoCommit(true); try (Statement tenantStmt = viewConn.createStatement()) { tenantStmt.execute("CREATE VIEW IF NOT EXISTS " + this.descViewName + " AS SELECT * FROM " + fullViewName); @@ -991,7 +992,7 @@ private void buildSchema(String fullTableName, String fullViewName, boolean isDe stmt.execute("CREATE VIEW " + fullViewName + "(\n" + " ID1 VARCHAR NOT NULL,\n" + " ID2 VARCHAR NOT NULL,\n" + " ID3 BIGINT, ID4 BIGINT \n" + " CONSTRAINT PKVIEW PRIMARY KEY\n" + " (ID1, ID2)) " + "AS SELECT * FROM " + fullTableName + " WHERE KEY_PREFIX = '0CY'"); - try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1)) { + try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { viewConn.setAutoCommit(true); try (Statement tenantStmt = viewConn.createStatement()) { tenantStmt.execute("CREATE VIEW IF NOT EXISTS " + this.ascViewName + " AS SELECT * FROM " + fullViewName); @@ -1005,8 +1006,7 @@ private void buildSchema(String fullTableName, String fullViewName, boolean isDe @Test public void testPkDescOrderedTenantViewOnGlobalViewWithRightQueryPlan() throws Exception { String tenantView = generateUniqueName(); - - try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1)) { + try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { viewConn.setAutoCommit(true); try (Statement stmt = viewConn.createStatement()) { stmt.execute("CREATE VIEW IF NOT EXISTS " + tenantView + " AS SELECT * FROM " + descViewName); @@ -1053,7 +1053,7 @@ public void testPkDescOrderedTenantViewOnGlobalViewWithRightQueryPlan() throws E public void testColumnDescOrderedTenantViewOnGlobalViewWithStringValue() throws Exception { String tenantView = generateUniqueName(); - try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1)) { + try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { viewConn.setAutoCommit(true); try (Statement stmt = viewConn.createStatement()) { stmt.execute("CREATE VIEW IF NOT EXISTS " + tenantView + " AS SELECT * FROM " + descViewName); @@ -1110,7 +1110,7 @@ public void testColumnDescOrderedTenantViewOnGlobalViewWithStringValue() throws public void testInListExpressionWithRightQueryPlanForTenantViewOnGlobalView() throws Exception { String tenantView = generateUniqueName(); - try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1)) { + try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { viewConn.setAutoCommit(true); try (Statement stmt = viewConn.createStatement()) { stmt.execute("CREATE VIEW IF NOT EXISTS " + tenantView + " AS SELECT * FROM " + ascViewName); @@ -1178,7 +1178,7 @@ public void testInListExpressionGeneratesRightScanForDesc() throws Exception { private void testFullPkListPlan(String tenantView) throws Exception { Long numberOfRowsToScan = new Long(2); - try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1) ) { + try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES)) ) { PreparedStatement preparedStmt = viewConn.prepareStatement("SELECT * FROM " + tenantView + " WHERE (ID1, ID2) IN " + "(('005xx000001Sv6o', '000000000000500')," + "('005xx000001Sv6o', '000000000000400'))"); @@ -1203,7 +1203,7 @@ private void testFullPkListPlan(String tenantView) throws Exception { } private void testPartialPkListPlan(String tenantView) throws Exception { - try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1) ) { + try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES)) ) { PreparedStatement preparedStmt = viewConn.prepareStatement("SELECT * FROM " + tenantView + " WHERE (ID1) IN " + "(('005xx000001Sv6o')," + "('005xx000001Sv6o'))"); @@ -1242,7 +1242,7 @@ private void testPartialPkListPlan(String tenantView) throws Exception { } private void testPartialPkPlusNonPkListPlan(String tenantView) throws Exception { - try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1) ) { + try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES)) ) { PreparedStatement preparedStmt = viewConn.prepareStatement("SELECT * FROM " + tenantView + " WHERE (ID1, ID3) IN " + "(('005xx000001Sv6o', 1)," + "('005xx000001Sv6o', 2))"); @@ -1282,7 +1282,7 @@ private void testPartialPkPlusNonPkListPlan(String tenantView) throws Exception private void testNonPkListPlan(String tenantView) throws Exception { // Tenant connection should generate a range scan because tenant id is the leading PK. - try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1) ) { + try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES)) ) { PreparedStatement preparedStmt = viewConn.prepareStatement("SELECT * FROM " + tenantView + " WHERE (ID3, ID4) IN " + "((1, 1)," + "(2, 2))"); @@ -1304,7 +1304,7 @@ private void testNonPkListPlan(String tenantView) throws Exception { } private void deleteTenantData(String tenantView) throws SQLException { - try (Connection tenantConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1)) { + try (Connection tenantConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { tenantConn.createStatement().execute("DELETE FROM " + tenantView); } } @@ -1312,8 +1312,7 @@ private void deleteTenantData(String tenantView) throws SQLException { @Test public void testInListExpressionWithRightQueryPlanForNumericalValue() throws Exception { String tenantView = generateUniqueName(); - - try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1)) { + try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { viewConn.setAutoCommit(true); try (Statement stmt = viewConn.createStatement()) { stmt.execute("CREATE VIEW IF NOT EXISTS " + tenantView + "(DOUBLE1 DOUBLE NOT NULL, INT1 BIGINT NOT NULL " + @@ -1346,8 +1345,7 @@ public void testInListExpressionWithRightQueryPlanForNumericalValue() throws Exc @Test public void testQueryPlanForPkDescOrderedTenantViewOnGlobalViewForStringValue() throws Exception { String tenantView = generateUniqueName(); - - try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1)) { + try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { viewConn.setAutoCommit(true); try (Statement stmt = viewConn.createStatement()) { stmt.execute("CREATE VIEW IF NOT EXISTS " + tenantView + " AS SELECT * FROM " + descViewName); @@ -1385,8 +1383,7 @@ public void testQueryPlanForPkDescOrderedTenantViewOnGlobalViewForStringValue() @Test public void testQueryPlanForTenantViewOnBaseTableWithVarcharValue() throws Exception { String tenantView = generateUniqueName(); - - try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1)) { + try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1,PropertiesUtil.deepCopy(TEST_PROPERTIES))) { viewConn.setAutoCommit(true); try (Statement stmt = viewConn.createStatement()) { stmt.execute("CREATE VIEW IF NOT EXISTS " + tenantView + "(DOUBLE1 VARCHAR NOT NULL, INT1 VARCHAR NOT NULL " + @@ -1420,7 +1417,7 @@ public void testQueryPlanForTenantViewOnBaseTableWithVarcharValue() throws Excep public void testQueryPlanForTenantViewOnBaseTableWithNumericalValue() throws Exception { String tenantView = generateUniqueName(); - try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1)) { + try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1,PropertiesUtil.deepCopy(TEST_PROPERTIES))) { viewConn.setAutoCommit(true); try (Statement stmt = viewConn.createStatement()) { stmt.execute("CREATE VIEW IF NOT EXISTS " + tenantView + @@ -1485,7 +1482,7 @@ public void testQueryPlanForTenantViewOnBaseTableWithNumericalValue() throws Exc public void testInListExpressionWithFunction() throws Exception { String tenantView = generateUniqueName(); - try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1)) { + try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1,PropertiesUtil.deepCopy(TEST_PROPERTIES))) { viewConn.setAutoCommit(true); try (Statement stmt = viewConn.createStatement()) { stmt.execute("CREATE VIEW IF NOT EXISTS " + tenantView + "(ID1 BIGINT NOT NULL, ID2 BIGINT NOT NULL, ID4 BIGINT " + @@ -1549,7 +1546,7 @@ public void testInListExpressionWithFunctionAndIndex() throws Exception { String tenantView = generateUniqueName(); String tenantIndexView = generateUniqueName(); - try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1)) { + try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { viewConn.setAutoCommit(true); try (Statement stmt = viewConn.createStatement()) { stmt.execute("CREATE VIEW IF NOT EXISTS " + tenantView + "(ID1 BIGINT NOT NULL, ID2 BIGINT NOT NULL, ID4 BIGINT " + @@ -1615,7 +1612,7 @@ public void testInListExpressionWithIndex() throws Exception { String tenantView = generateUniqueName(); String tenantIndexView = generateUniqueName(); - try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1)) { + try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { viewConn.setAutoCommit(true); try (Statement stmt = viewConn.createStatement()) { stmt.execute("CREATE VIEW IF NOT EXISTS " + tenantView + "(ID1 BIGINT NOT NULL, ID2 BIGINT NOT NULL, ID4 BIGINT " + @@ -1681,14 +1678,13 @@ public void testInListExpressionWithGlobalViewAndFunction() throws Exception { String tenantView = generateUniqueName(); String globalView = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.setAutoCommit(true); try (Statement stmt = conn.createStatement()) { stmt.execute("CREATE VIEW " + globalView + " AS SELECT * FROM " + tableName + " WHERE KEY_PREFIX = 'ABC'"); } } - - try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1)) { + try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { viewConn.setAutoCommit(true); try (Statement stmt = viewConn.createStatement()) { stmt.execute("CREATE VIEW IF NOT EXISTS " + tenantView + "(ID1 BIGINT NOT NULL, ID2 BIGINT NOT NULL, ID4 BIGINT " + @@ -1752,14 +1748,14 @@ public void testGlobalViewWithPowerFunction() throws Exception { String tenantView = generateUniqueName(); String globalView = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.setAutoCommit(true); try (Statement stmt = conn.createStatement()) { stmt.execute("CREATE VIEW " + globalView + " AS SELECT * FROM " + tableName + " WHERE KEY_PREFIX = 'ABC'"); } } - try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1)) { + try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1,PropertiesUtil.deepCopy(TEST_PROPERTIES))) { viewConn.setAutoCommit(true); try (Statement stmt = viewConn.createStatement()) { stmt.execute("CREATE VIEW IF NOT EXISTS " + tenantView + "(ID1 DOUBLE NOT NULL, ID2 DOUBLE NOT NULL, ID4 BIGINT " + @@ -1798,7 +1794,7 @@ public void testBaseTableAndIndexTableHaveReversePKOrder() throws Exception { String view = generateUniqueName(); String index = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(TENANT_SPECIFIC_URL1)) { + try (Connection conn = DriverManager.getConnection(TENANT_SPECIFIC_URL1,PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.setAutoCommit(true); try (Statement stmt = conn.createStatement()) { stmt.execute("CREATE VIEW " + view + " (ID1 BIGINT NOT NULL, ID2 BIGINT NOT NULL, ID4 BIGINT " + @@ -1867,7 +1863,7 @@ public void testDeletionFromTenantViewAndViewIndex() throws Exception { String view = generateUniqueName(); String index = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(TENANT_SPECIFIC_URL1)) { + try (Connection conn = DriverManager.getConnection(TENANT_SPECIFIC_URL1,PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.setAutoCommit(true); try (Statement stmt = conn.createStatement()) { stmt.execute("CREATE VIEW " + view + " (ID1 BIGINT NOT NULL, ID2 BIGINT NOT NULL, ID4 BIGINT " + @@ -1936,7 +1932,7 @@ public void testBaseTableAndIndexTableHaveRightScan() throws Exception { String index = generateUniqueName(); String fullTableName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.setAutoCommit(true); try (Statement stmt = conn.createStatement()) { stmt.execute("CREATE TABLE " + fullTableName + "(ID1 BIGINT NOT NULL, ID2 BIGINT NOT NULL, " + @@ -1958,7 +1954,7 @@ public void testBaseTableAndIndexTableHaveRightScan() throws Exception { @Test public void testInListExpressionWithVariableLengthColumnsRanges() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); final String schemaName = generateUniqueName(); final String tableName = generateUniqueName(); final String dataTableFullName = SchemaUtil.getTableName(schemaName, tableName); @@ -2075,7 +2071,7 @@ private void testTSVarVarPKs(int tenantId, String viewName, SortOrder[] sortOrde String testMaxInList = String.format("SELECT ROW_ID FROM %s WHERE (ID1, ID2, ID3) IN ((%d, '4', '5'),(%d, '2', '3')", viewName, nowTime+1, nowTime+1); String tenantConnectionUrl = String.format("%s;%s=%s%06d", getUrl(), TENANT_ID_ATTRIB, TENANT_PREFIX, tenantId); - try (Connection tenantConnection = DriverManager.getConnection(tenantConnectionUrl)) { + try (Connection tenantConnection = DriverManager.getConnection(tenantConnectionUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { tenantConnection.setAutoCommit(true); try (Statement ustmt = tenantConnection.createStatement()) { for (String upsertSql : UPSERT_SQLS) { @@ -2125,7 +2121,7 @@ private void testVarVarVarPKs(int tenantId, String viewName, SortOrder[] sortOrd String testMaxInList = String.format("SELECT ROW_ID FROM %s WHERE (ID1, ID2, ID3) IN (('%s', '4', '5'),('%s', '2', '3')", viewName, nowTime+2, nowTime+1); String tenantConnectionUrl = String.format("%s;%s=%s%06d", getUrl(), TENANT_ID_ATTRIB, TENANT_PREFIX, tenantId); - try (Connection tenantConnection = DriverManager.getConnection(tenantConnectionUrl)) { + try (Connection tenantConnection = DriverManager.getConnection(tenantConnectionUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { tenantConnection.setAutoCommit(true); try (Statement ustmt = tenantConnection.createStatement()) { for (String upsertSql : UPSERT_SQLS) { @@ -2164,7 +2160,7 @@ private void testIntDecIntPK(int tenantId, String viewName, SortOrder[] sortOrde String testMaxInList = String.format("SELECT ROW_ID FROM %s WHERE (ID1, ID2, ID3) IN ((%d, 21.0, 3),(%d, 2.0, 3)", viewName, nowTime+1, nowTime+1); String tenantConnectionUrl = String.format("%s;%s=%s%06d", getUrl(), TENANT_ID_ATTRIB, TENANT_PREFIX, tenantId); - try (Connection tenantConnection = DriverManager.getConnection(tenantConnectionUrl)) { + try (Connection tenantConnection = DriverManager.getConnection(tenantConnectionUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { tenantConnection.setAutoCommit(true); try (Statement ustmt = tenantConnection.createStatement()) { for (String upsertSql : UPSERT_SQLS) { @@ -2193,7 +2189,7 @@ private void assertExpectedWithWhere(int tenantId, String testType, String test String context = "sql: " + testSQL + ", type: " + testType; String tenantConnectionUrl = String.format("%s;%s=%s%06d", getUrl(), TENANT_ID_ATTRIB, TENANT_PREFIX, tenantId); - try (Connection tenantConnection = DriverManager.getConnection(tenantConnectionUrl)) { + try (Connection tenantConnection = DriverManager.getConnection(tenantConnectionUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { // perform the query ResultSet rs = tenantConnection.createStatement().executeQuery(testSQL); for (int i = 0; i < expectedSet.size();i++) { @@ -2217,7 +2213,7 @@ private void assertExpectedWithMaxInList(int tenantId, String testType, PDataTy query.append(")"); String tenantConnectionUrl = String.format("%s;%s=%s%06d", getUrl(), TENANT_ID_ATTRIB, TENANT_PREFIX, tenantId); - try (Connection tenantConnection = DriverManager.getConnection(tenantConnectionUrl)) { + try (Connection tenantConnection = DriverManager.getConnection(tenantConnectionUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { PhoenixPreparedStatement stmt = tenantConnection.prepareStatement(query.toString()).unwrap(PhoenixPreparedStatement.class); // perform the query int lastBoundCol = 0; @@ -2250,7 +2246,7 @@ public void testSkipScanCardinalityOverflow() throws SQLException { final String viewName = String.format("Z_%s", baseTableName); int tenantId = 1; - try (Connection globalConnection = DriverManager.getConnection(getUrl())) { + try (Connection globalConnection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { try (Statement cstmt = globalConnection.createStatement()) { String createDDL = "CREATE TABLE IF NOT EXISTS " + baseTableName + "(OID CHAR(15) NOT NULL, KP CHAR(3) NOT NULL, CREATED_DATE DATE, CREATED_BY CHAR(15), SYSTEM_MODSTAMP DATE " + @@ -2260,7 +2256,7 @@ public void testSkipScanCardinalityOverflow() throws SQLException { } String tenantConnectionUrl = String.format("%s;%s=%s%06d", getUrl(), TENANT_ID_ATTRIB, TENANT_PREFIX, tenantId); - try (Connection tenantConnection = DriverManager.getConnection(tenantConnectionUrl)) { + try (Connection tenantConnection = DriverManager.getConnection(tenantConnectionUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { try (Statement cstmt = tenantConnection.createStatement()) { // DESC order in PK causes key explosion when creating skip scan String TENANT_VIEW_TEMPLATE = "CREATE VIEW IF NOT EXISTS %s " + diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/InQueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/InQueryIT.java index 4d24ff66c5a..d89ef1ffd8f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/InQueryIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/InQueryIT.java @@ -49,7 +49,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.runners.Parameterized.Parameters; - @Category(ParallelStatsDisabledTest.class) public class InQueryIT extends BaseQueryIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexBuildTimestampIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexBuildTimestampIT.java index e5d737fe887..7ef4ee99dbb 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexBuildTimestampIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexBuildTimestampIT.java @@ -17,6 +17,8 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +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.assertNotNull; @@ -35,6 +37,7 @@ import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.client.Table; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixResultSet; import org.apache.phoenix.query.BaseTest; import org.apache.phoenix.query.QueryServices; @@ -42,7 +45,7 @@ import org.apache.phoenix.schema.PTable; import org.apache.phoenix.util.EnvironmentEdge; import org.apache.phoenix.util.EnvironmentEdgeManager; -import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.QueryUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.junit.BeforeClass; @@ -55,7 +58,6 @@ import org.apache.phoenix.thirdparty.com.google.common.collect.Lists; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; import org.apache.phoenix.transaction.TransactionFactory; - @Category(NeedsOwnMiniClusterTest.class) @RunWith(Parameterized.class) public class IndexBuildTimestampIT extends BaseTest { @@ -102,8 +104,13 @@ public static synchronized void setup() throws Exception { clientProps.put(QueryServices.STATS_UPDATE_FREQ_MS_ATTRIB, Long.toString(5)); clientProps.put(QueryServices.TRANSACTIONS_ENABLED, Boolean.TRUE.toString()); clientProps.put(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, Boolean.TRUE.toString()); - setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), - new ReadOnlyProps(clientProps.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(serverProps.entrySet().iterator()), new ReadOnlyProps(clientProps.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), + new ReadOnlyProps(clientProps.entrySet().iterator())); + } + ; } @Parameters( @@ -162,7 +169,7 @@ public long initialTime() { } private void populateTable(String tableName, MyClock clock1, MyClock clock2) throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute("create table " + tableName + " (id varchar(10) not null primary key, val varchar(10), ts timestamp)" + tableDDLOptions); @@ -175,7 +182,7 @@ private void populateTable(String tableName, MyClock clock1, MyClock clock2) thr conn.commit(); conn.close(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty("CurrentSCN", Long.toString(clock1.initialTime())); conn = DriverManager.getConnection(getUrl(), props); ResultSet rs = conn.createStatement().executeQuery("select * from " + tableName); @@ -223,10 +230,10 @@ public void testCellTimestamp() throws Exception { MyClock clock3 = new MyClock(300000); EnvironmentEdgeManager.injectEdge(clock3); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, "true"); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_DELETE_MUTATIONS, "true"); - PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl(), props); + PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), props); String viewName = null; if (view) { @@ -247,7 +254,7 @@ public void testCellTimestamp() throws Exception { // Verify the index timestamps via Phoenix String selectSql = String.format("SELECT * FROM %s WHERE val = 'abc'", (view ? viewName : dataTableName)); - conn = (PhoenixConnection) DriverManager.getConnection(getUrl()); + conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)); // assert we are pulling from index table assertExplainPlan(conn, localIndex, selectSql, dataTableName, (view && !localIndex ? "_IDX_" + dataTableName : indexName)); @@ -271,7 +278,7 @@ public void testCellTimestamp() throws Exception { // Verify the index timestamps via HBase PTable pIndexTable = conn.getTable(indexName); - Table table = conn.unwrap(PhoenixConnection.class).getQueryServices() + Table table = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices() .getTable(pIndexTable.getPhysicalName().getBytes()); Scan scan = new Scan(); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexExtendedIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexExtendedIT.java index 3fc92969b17..43ebaebf7ff 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexExtendedIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexExtendedIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.apache.phoenix.util.TestUtil.checkIndexState; import static org.apache.phoenix.util.TestUtil.getRowCount; @@ -42,6 +43,7 @@ import org.apache.phoenix.coprocessor.IndexRebuildRegionScanner; import org.apache.phoenix.coprocessorclient.BaseScannerRegionObserverConstants; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixPreparedStatement; import org.apache.phoenix.mapreduce.index.IndexTool; import org.apache.phoenix.query.BaseTest; @@ -107,6 +109,13 @@ public static synchronized void doSetup() throws Exception { clientProps.put(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, Boolean.TRUE.toString()); setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), new ReadOnlyProps(clientProps.entrySet() .iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(serverProps.entrySet().iterator()), new ReadOnlyProps(clientProps.entrySet() + .iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), new ReadOnlyProps(clientProps.entrySet() + .iterator())); + } } @Parameters(name="mutable = {0} , localIndex = {1}, useViewIndex = {2}, useSnapshot = {3}") @@ -327,7 +336,7 @@ public void testBuildDisabledIndex() throws Exception { baseTableNameOfIndex = viewName; physicalTableNameOfIndex = "_IDX_" + dataTableFullName; } - Table hIndexTable = conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(Bytes.toBytes(physicalTableNameOfIndex)); + Table hIndexTable = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getTable(Bytes.toBytes(physicalTableNameOfIndex)); stmt.execute( String.format("CREATE INDEX %s ON %s (UPPER(NAME, 'en_US')) %s", indexName, diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexRebuildTaskIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexRebuildTaskIT.java index eb597ed5e09..a40f7dfdef5 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexRebuildTaskIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexRebuildTaskIT.java @@ -25,6 +25,7 @@ import org.apache.phoenix.coprocessor.TaskRegionObserver; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.BaseTest; import org.apache.phoenix.query.ConnectionQueryServices; import org.apache.phoenix.query.QueryServicesOptions; @@ -49,11 +50,11 @@ import java.util.HashMap; import java.util.Properties; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.apache.phoenix.util.TestUtil.waitForIndexRebuild; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; - @Category(NeedsOwnMiniClusterTest.class) public class IndexRebuildTaskIT extends BaseTest { protected static String TENANT1 = "tenant1"; @@ -63,6 +64,11 @@ public class IndexRebuildTaskIT extends BaseTest { public static synchronized void doSetup() throws Exception { HashMap props = new HashMap<>(); setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()), new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } TaskRegionEnvironment = getUtility() .getRSForFirstRegionInTable( @@ -88,7 +94,7 @@ public void testIndexRebuildTask() throws Throwable { Connection conn = null; Connection tenantConn = null; try { - conn = DriverManager.getConnection(getUrl()); + conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.setAutoCommit(false); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, TENANT1); @@ -121,7 +127,7 @@ public void testIndexRebuildTask() throws Throwable { waitForIndexRebuild(conn, indexName, PIndexState.ACTIVE); String viewIndexTableName = MetaDataUtil.getViewIndexPhysicalName(baseTable); - ConnectionQueryServices queryServices = conn.unwrap(PhoenixConnection.class).getQueryServices(); + ConnectionQueryServices queryServices = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); Table indexHTable = queryServices.getTable(Bytes.toBytes(viewIndexTableName)); int count = getUtility().countRows(indexHTable); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexRepairRegionScannerIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexRepairRegionScannerIT.java index 7d31ce48fe3..0a4b2711d03 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexRepairRegionScannerIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexRepairRegionScannerIT.java @@ -18,6 +18,7 @@ package org.apache.phoenix.end2end; import org.apache.phoenix.coprocessorclient.BaseScannerRegionObserverConstants; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.Cell; @@ -76,6 +77,7 @@ import java.util.Map; import java.util.Properties; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.mapreduce.index.IndexVerificationResultRepository.RESULT_TABLE_NAME; import static org.apache.phoenix.mapreduce.index.PhoenixIndexToolJobCounters.AFTER_REPAIR_EXTRA_UNVERIFIED_INDEX_ROW_COUNT; import static org.apache.phoenix.mapreduce.index.PhoenixIndexToolJobCounters.AFTER_REPAIR_EXTRA_VERIFIED_INDEX_ROW_COUNT; @@ -93,7 +95,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; - @Category(NeedsOwnMiniClusterTest.class) @RunWith(Parameterized.class) public class IndexRepairRegionScannerIT extends ParallelStatsDisabledIT { @@ -142,7 +143,11 @@ public static synchronized void doSetup() throws Exception { // to force multiple verification tasks to be spawned so that we can exercise the page splitting logic props.put(GlobalIndexRegionScanner.INDEX_VERIFY_ROW_COUNTS_PER_TASK_CONF_KEY, Long.toString(2)); props.put("hbase.procedure.remote.dispatcher.delay.msec", "0"); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()), new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @Before @@ -170,9 +175,9 @@ public void cleanup() throws Exception { } private void setIndexRowStatusesToVerified(Connection conn, String dataTableFullName, String indexTableFullName) throws Exception { - PTable pDataTable = conn.unwrap(PhoenixConnection.class).getTable(dataTableFullName); - PTable pIndexTable = conn.unwrap(PhoenixConnection.class).getTable(indexTableFullName); - Table hTable = conn.unwrap(PhoenixConnection.class).getQueryServices() + PTable pDataTable = conn.unwrap(PhoenixMonitoredConnection.class).getTable(dataTableFullName); + PTable pIndexTable = conn.unwrap(PhoenixMonitoredConnection.class).getTable(indexTableFullName); + Table hTable = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices() .getTable(pIndexTable.getPhysicalName().getBytes()); Scan scan = new Scan(); PhoenixConnection phoenixConnection = conn.unwrap(PhoenixConnection.class); @@ -840,7 +845,7 @@ public void testDisableOutputLogging() throws Exception { public void deleteAllRows(Connection conn, TableName tableName) throws SQLException, IOException, InterruptedException { Scan scan = new Scan(); - Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices(). + Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices(). getAdmin(); org.apache.hadoop.hbase.client.Connection hbaseConn = admin.getConnection(); Table table = hbaseConn.getTable(tableName); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexScrutinyToolBaseIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexScrutinyToolBaseIT.java index 7f652c5fefd..9ff1ab517f3 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexScrutinyToolBaseIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexScrutinyToolBaseIT.java @@ -34,6 +34,7 @@ import java.util.Map; import java.util.UUID; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -60,7 +61,11 @@ public class IndexScrutinyToolBaseIT extends BaseTest { if (!previousIndexRegionObserverEnabled.equals(indexRegionObserverEnabled)) { driver = null; } - setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), new ReadOnlyProps(clientProps.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(serverProps.entrySet().iterator()), new ReadOnlyProps(clientProps.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), new ReadOnlyProps(clientProps.entrySet().iterator())); + } previousIndexRegionObserverEnabled = indexRegionObserverEnabled; } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexScrutinyToolForTenantIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexScrutinyToolForTenantIT.java index 49be8212af8..6d215ad09ae 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexScrutinyToolForTenantIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexScrutinyToolForTenantIT.java @@ -10,6 +10,7 @@ */ package org.apache.phoenix.end2end; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.thirdparty.com.google.common.base.Joiner; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.Admin; @@ -166,7 +167,7 @@ public void teardown() throws Exception { connGlobal.createStatement() .execute(String.format(createIndexStr, indexNameGlobal, multiTenantTable)); - PhoenixConnection pconn = connGlobal.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pconn = connGlobal.unwrap(PhoenixMonitoredConnection.class); PTable pDataTable = pconn.getTable(new PTableKey(null, multiTenantTable)); PTable pIndexTable = pconn.getTable(new PTableKey(null, indexNameGlobal)); @@ -241,7 +242,7 @@ private void testWithOutput(OutputFormat outputFormat) throws Exception { indexNameTenant, 5555, "wrongName")); connTenant.commit(); - ConnectionQueryServices queryServices = connGlobal.unwrap(PhoenixConnection.class).getQueryServices(); + ConnectionQueryServices queryServices = connGlobal.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); Admin admin = queryServices.getAdmin(); TableName tableName = TableName.valueOf(viewIndexTableName); admin.disableTable(tableName); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexScrutinyWithMaxLookbackIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexScrutinyWithMaxLookbackIT.java index 58f2da9fefa..382b38f766d 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexScrutinyWithMaxLookbackIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexScrutinyWithMaxLookbackIT.java @@ -46,6 +46,7 @@ import java.util.List; import java.util.Map; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.mapreduce.index.PhoenixScrutinyJobCounters.INVALID_ROW_COUNT; import static org.apache.phoenix.mapreduce.index.PhoenixScrutinyJobCounters.BEYOND_MAX_LOOKBACK_COUNT; import static org.apache.phoenix.mapreduce.index.PhoenixScrutinyJobCounters.VALID_ROW_COUNT; @@ -54,7 +55,6 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; - public class IndexScrutinyWithMaxLookbackIT extends IndexScrutinyToolBaseIT { private static PreparedStatement upsertDataStmt; @@ -82,7 +82,11 @@ public static synchronized void doSetup() throws Exception { props.put(BaseScannerRegionObserverConstants.PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY, Integer.toString(MAX_LOOKBACK)); props.put("hbase.procedure.remote.dispatcher.delay.msec", "0"); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @Before diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolForDeleteBeforeRebuildIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolForDeleteBeforeRebuildIT.java index 0171a0ca096..26204022b15 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolForDeleteBeforeRebuildIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolForDeleteBeforeRebuildIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.thirdparty.com.google.common.collect.Lists; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; import org.apache.hadoop.conf.Configuration; @@ -48,10 +49,10 @@ import java.util.Properties; import java.util.UUID; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; - @Category(ParallelStatsDisabledTest.class) public class IndexToolForDeleteBeforeRebuildIT extends ParallelStatsDisabledIT { private Connection conn; @@ -85,8 +86,14 @@ public static synchronized void setup() throws Exception { clientProps.put(QueryServices.STATS_UPDATE_FREQ_MS_ATTRIB, Long.toString(5)); clientProps.put(QueryServices.TRANSACTIONS_ENABLED, Boolean.TRUE.toString()); clientProps.put(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, Boolean.TRUE.toString()); - setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), - new ReadOnlyProps(clientProps.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(serverProps.entrySet().iterator()), + new ReadOnlyProps(clientProps.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), + new ReadOnlyProps(clientProps.entrySet().iterator())); + } + } @Before @@ -152,8 +159,8 @@ public void testDeleteBeforeRebuildForGlobalIndex() throws Exception { upsertRow(stmt, "tenantID1",11, "name11", 99911); conn.commit(); - ConnectionQueryServices queryServices = conn.unwrap(PhoenixConnection.class).getQueryServices(); - PTable physicalTable = conn.unwrap(PhoenixConnection.class).getTable(globalIndexFullName); + ConnectionQueryServices queryServices = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); + PTable physicalTable = conn.unwrap(PhoenixMonitoredConnection.class).getTable(globalIndexFullName); Table hIndexTable= queryServices.getTable(physicalTable.getPhysicalName().getBytes()); int count = getUtility().countRows(hIndexTable); // Confirm index has rows. diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolForNonTxGlobalIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolForNonTxGlobalIndexIT.java index e75a1f6dbbf..0c582bad263 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolForNonTxGlobalIndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolForNonTxGlobalIndexIT.java @@ -20,6 +20,7 @@ import org.apache.hadoop.hbase.coprocessor.RegionCoprocessor; import org.apache.hadoop.hbase.coprocessor.RegionObserver; import org.apache.phoenix.coprocessorclient.BaseScannerRegionObserverConstants; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.Cell; @@ -92,6 +93,7 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.mapreduce.PhoenixJobCounters.INPUT_RECORDS; import static org.apache.phoenix.mapreduce.index.IndexVerificationResultRepository.INDEX_TOOL_RUN_STATUS_BYTES; import static org.apache.phoenix.mapreduce.index.IndexVerificationResultRepository.RESULT_TABLE_COLUMN_FAMILY; @@ -124,7 +126,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; - @Category(NeedsOwnMiniClusterTest.class) @RunWith(Parameterized.class) public class IndexToolForNonTxGlobalIndexIT extends BaseTest { @@ -191,8 +192,13 @@ public static synchronized void setup() throws Exception { clientProps.put(QueryServices.TRANSACTIONS_ENABLED, Boolean.TRUE.toString()); clientProps.put(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, Boolean.TRUE.toString()); destroyDriver(); - setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), - new ReadOnlyProps(clientProps.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(serverProps.entrySet().iterator()), new ReadOnlyProps(clientProps.entrySet() + .iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), new ReadOnlyProps(clientProps.entrySet() + .iterator())); + } //IndexToolIT.runIndexTool pulls from the minicluster's config directly getUtility().getConfiguration().set(QueryServices.INDEX_REBUILD_RPC_RETRIES_COUNTER, "1"); } @@ -309,7 +315,7 @@ public void testIndexToolVerifyWithExpiredIndexRows() throws Exception { IndexTool.IndexVerifyType.AFTER); // Set ttl of index table ridiculously low so that all data is expired - Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin(); + Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin(); TableName indexTable = TableName.valueOf(indexTableFullName); ColumnFamilyDescriptor desc = admin.getDescriptor(indexTable).getColumnFamilies()[0]; @@ -326,7 +332,7 @@ public void testIndexToolVerifyWithExpiredIndexRows() throws Exception { IndexTool.IndexVerifyType.ONLY); Scan scan = new Scan(); Table hIndexToolTable = - conn.unwrap(PhoenixConnection.class).getQueryServices() + conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices() .getTable(indexToolOutputTable.getName()); Result r = hIndexToolTable.getScanner(scan).next(); assertNull(r); @@ -369,7 +375,7 @@ public void testSecondaryGlobalIndexFailure() throws Exception { // Verify that the index table is in the ACTIVE state assertEquals(PIndexState.ACTIVE, TestUtil.getIndexState(conn, qIndexTableName)); - ConnectionQueryServices queryServices = conn.unwrap(PhoenixConnection.class).getQueryServices(); + ConnectionQueryServices queryServices = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); Admin admin = queryServices.getAdmin(); TableName tn = TableName.valueOf(Bytes.toBytes(dataTableFullName)); TableDescriptor td = admin.getDescriptor(tn); @@ -1119,7 +1125,7 @@ public void testEnableOutputLoggingForMaxLookback() throws Exception { String indexTableName = generateUniqueName(); String indexTableFullName = SchemaUtil.getTableName(schemaName, indexTableName); - try(Connection conn = DriverManager.getConnection(getUrl())) { + try(Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { deleteAllRows(conn, TableName.valueOf(IndexVerificationOutputRepository.OUTPUT_TABLE_NAME)); @@ -1229,7 +1235,7 @@ public void testPointDeleteRebuildWithPageSize() throws Exception { String dataTableName = generateUniqueName(); String fullDataTableName = SchemaUtil.getTableName(schemaName, dataTableName); String indexTableName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute( "CREATE TABLE " + fullDataTableName + "(k VARCHAR PRIMARY KEY, v VARCHAR)"); conn.createStatement().execute("DELETE FROM " + fullDataTableName + " WHERE k = 'a'"); @@ -1275,7 +1281,7 @@ public void testIncrementalRebuildWithPageSize() throws Exception { String dataTableName = generateUniqueName(); String fullDataTableName = SchemaUtil.getTableName(schemaName, dataTableName); String indexTableName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { long minTs = EnvironmentEdgeManager.currentTimeMillis(); conn.createStatement().execute( "CREATE TABLE " + fullDataTableName + "(k VARCHAR PRIMARY KEY, v VARCHAR)"); @@ -1484,7 +1490,7 @@ private Pair countPutsAndDeletes(String tableName) throws Exce int numPuts = 0; int numDeletes = 0; try (org.apache.hadoop.hbase.client.Connection hcon = - ConnectionFactory.createConnection(config)) { + ConnectionFactory.createConnection(getConfiguration())) { Table htable = hcon.getTable(TableName.valueOf(tableName)); Scan scan = new Scan(); scan.setRaw(true); @@ -1506,7 +1512,7 @@ private Pair countPutsAndDeletes(String tableName) throws Exce public void deleteAllRows(Connection conn, TableName tableName) throws SQLException, IOException, InterruptedException { Scan scan = new Scan(); - Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices(). + Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices(). getAdmin(); org.apache.hadoop.hbase.client.Connection hbaseConn = admin.getConnection(); Table table = hbaseConn.getTable(tableName); @@ -1573,7 +1579,7 @@ private void assertDisableLogging(Connection conn, int expectedRows, private void deleteOneRowFromResultTable(Connection conn, Long scn, String indexTable) throws SQLException, IOException { - Table hIndexToolTable = conn.unwrap(PhoenixConnection.class).getQueryServices() + Table hIndexToolTable = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices() .getTable(RESULT_TABLE_NAME_BYTES); Scan s = new Scan(); s.setRowPrefixFilter(Bytes.toBytes(String.format("%s%s%s", scn, ROW_KEY_SEPARATOR, indexTable))); @@ -1582,7 +1588,7 @@ private void deleteOneRowFromResultTable(Connection conn, Long scn, String inde } private List verifyRunStatusFromResultTable(Connection conn, Long scn, String indexTable, int totalRows, List expectedStatus) throws SQLException, IOException { - Table hIndexToolTable = conn.unwrap(PhoenixConnection.class).getQueryServices() + Table hIndexToolTable = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices() .getTable(RESULT_TABLE_NAME_BYTES); Assert.assertEquals(totalRows, TestUtil.getRowCount(hIndexToolTable, false)); List output = new ArrayList<>(); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolForPartialBuildIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolForPartialBuildIT.java index 505ac8b01b6..f7f74f38db2 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolForPartialBuildIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolForPartialBuildIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -44,6 +45,7 @@ import org.apache.phoenix.compile.ExplainPlan; import org.apache.phoenix.compile.ExplainPlanAttributes; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixPreparedStatement; import org.apache.phoenix.mapreduce.index.IndexTool; import org.apache.phoenix.query.QueryServices; @@ -94,7 +96,11 @@ public static Map getServerProperties() { @BeforeClass public static synchronized void doSetup() throws Exception { Map serverProps = getServerProperties(); - setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), ReadOnlyProps.EMPTY_PROPS); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(serverProps.entrySet().iterator()), ReadOnlyProps.EMPTY_PROPS); + } else { + setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), ReadOnlyProps.EMPTY_PROPS); + } } @Test @@ -107,10 +113,10 @@ public void testSecondaryIndex() throws Exception { props.setProperty(QueryServices.TRANSACTIONS_ENABLED, Boolean.TRUE.toString()); props.setProperty(QueryServices.EXPLAIN_ROW_COUNT_ATTRIB, Boolean.FALSE.toString()); props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.toString(isNamespaceEnabled)); - final PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl(), + final PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), props); Statement stmt = conn.createStatement(); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin();){ + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin();){ if (isNamespaceEnabled) { conn.createStatement().execute("CREATE SCHEMA IF NOT EXISTS " + schemaName); } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolForPartialBuildWithNamespaceEnabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolForPartialBuildWithNamespaceEnabledIT.java index 389aad4e473..50deb7e2767 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolForPartialBuildWithNamespaceEnabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolForPartialBuildWithNamespaceEnabledIT.java @@ -31,6 +31,8 @@ import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; + /** * Tests for the {@link IndexToolForPartialBuildWithNamespaceEnabled} */ @@ -51,7 +53,11 @@ public static void doSetup() throws Exception { serverProps.put(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, "true"); Map clientProps = Maps.newHashMapWithExpectedSize(1); clientProps.put(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, "true"); - setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), new ReadOnlyProps(clientProps.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(serverProps.entrySet().iterator()), new ReadOnlyProps(clientProps.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), new ReadOnlyProps(clientProps.entrySet().iterator())); + } } @Parameters(name="isNamespaceEnabled = {0}") diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolIT.java index cef5d90433f..8281695c428 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.mapreduce.PhoenixJobCounters.INPUT_RECORDS; import static org.apache.phoenix.mapreduce.index.PhoenixIndexToolJobCounters.AFTER_REBUILD_BEYOND_MAXLOOKBACK_INVALID_INDEX_ROW_COUNT; import static org.apache.phoenix.mapreduce.index.PhoenixIndexToolJobCounters.AFTER_REBUILD_BEYOND_MAXLOOKBACK_MISSING_INDEX_ROW_COUNT; @@ -84,7 +85,7 @@ import org.apache.phoenix.compile.ExplainPlan; import org.apache.phoenix.compile.ExplainPlanAttributes; import org.apache.phoenix.end2end.index.IndexTestUtil; -import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixPreparedStatement; import org.apache.phoenix.mapreduce.index.IndexTool; import org.apache.phoenix.mapreduce.index.IndexVerificationOutputRepository; @@ -117,7 +118,6 @@ import org.junit.runners.Parameterized.Parameters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - @Category(NeedsOwnMiniClusterTest.class) @RunWith(Parameterized.class) public class IndexToolIT extends BaseTest { @@ -170,7 +170,7 @@ public static synchronized void setup( String transactionProvider, boolean mutable, boolean localIndex, boolean useSnapshot, boolean useTenantId, boolean namespaceMapped) throws Exception { - if (clusterInitialized && Boolean.valueOf(namespaceMapped).equals(utility.getConfiguration() + if (clusterInitialized && Boolean.valueOf(namespaceMapped).equals(getUtility().getConfiguration() .getBoolean(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, true))) { //Perf optimization: no need to re-initialize the minicluster return; @@ -199,8 +199,13 @@ public static synchronized void setup( clientProps.put(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, Boolean.TRUE.toString()); clientProps.put(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.toString(namespaceMapped)); - setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), - new ReadOnlyProps(clientProps.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(serverProps.entrySet().iterator()), + new ReadOnlyProps(clientProps.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), + new ReadOnlyProps(clientProps.entrySet().iterator())); + } } } @@ -257,7 +262,7 @@ public void testSecondaryIndex() throws Exception { String indexTableName = generateUniqueName(); String indexTableFullName = SchemaUtil.getTableName(schemaName, indexTableName); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl(), props); + PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), props); try { if(namespaceMapped) { conn.createStatement().execute("CREATE SCHEMA " + schemaName); @@ -391,7 +396,7 @@ public void testSecondaryIndex() throws Exception { } protected static void dropIndexToolTables(Connection conn) throws Exception { - Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin(); + Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin(); TableName indexToolOutputTable = TableName.valueOf(IndexVerificationOutputRepository.OUTPUT_TABLE_NAME_BYTES); admin.disableTable(indexToolOutputTable); @@ -439,7 +444,7 @@ public static Cell getErrorMessageFromIndexToolOutputTable(Connection conn, Stri throws Exception { byte[] indexTableFullNameBytes = Bytes.toBytes(indexTableFullName); byte[] dataTableFullNameBytes = Bytes.toBytes(dataTableFullName); - Table hIndexTable = conn.unwrap(PhoenixConnection.class).getQueryServices() + Table hIndexTable = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices() .getTable(IndexVerificationOutputRepository.OUTPUT_TABLE_NAME_BYTES); Scan scan = new Scan(); ResultScanner scanner = hIndexTable.getScanner(scan); @@ -474,7 +479,7 @@ public static Cell getErrorMessageFromIndexToolOutputTable(Connection conn, Stri assertTrue("IndexTableNameCheck was false", indexTableNameCheck); assertTrue("Error message cell was null", errorMessageCell != null); verifyIndexTableRowKey(CellUtil.cloneRow(errorMessageCell), indexTableFullName); - hIndexTable = conn.unwrap(PhoenixConnection.class).getQueryServices() + hIndexTable = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices() .getTable(IndexVerificationResultRepository.RESULT_TABLE_NAME_BYTES); scan = new Scan(); scanner = hIndexTable.getScanner(scan); @@ -544,7 +549,7 @@ public void testIndexToolWithTenantId() throws Exception { assertFalse(rs.next()); // Remove from tenant view index and build. - ConnectionQueryServices queryServices = connGlobal.unwrap(PhoenixConnection.class).getQueryServices(); + ConnectionQueryServices queryServices = connGlobal.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); Admin admin = queryServices.getAdmin(); TableName tableName = TableName.valueOf(viewIndexTableName); admin.disableTable(tableName); @@ -638,7 +643,7 @@ public void testSplitIndex() throws Exception { String indexTableName = generateUniqueName(); try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); - Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { if(namespaceMapped) { conn.createStatement().execute("CREATE SCHEMA " + schemaName); } @@ -988,8 +993,8 @@ private static void verifyMapper(Job job, boolean useSnapshot, String schemaName props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); } - try (PhoenixConnection conn = - (PhoenixConnection) DriverManager.getConnection(getUrl(), props)) { + try (PhoenixMonitoredConnection conn = + (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), props)) { PTable indexTable = conn.getTableNoCache(SchemaUtil .normalizeFullTableName(SchemaUtil.getTableName(schemaName, indexTableName))); PTable dataTable = conn.getTableNoCache(SchemaUtil @@ -1082,7 +1087,7 @@ public static long verifyIndexTable(String fullTableName, assertEquals(0, counters.findCounter(BEFORE_REBUILD_BEYOND_MAXLOOKBACK_INVALID_INDEX_ROW_COUNT).getValue()); // The index scrutiny run will trigger index repair on all unverified rows, and they will be repaired or // deleted (since the age threshold is set to zero ms for these tests - PTable pIndexTable = conn.unwrap(PhoenixConnection.class).getTable(fullIndexName); + PTable pIndexTable = conn.unwrap(PhoenixMonitoredConnection.class).getTable(fullIndexName); if (pIndexTable.getIndexType() != PTable.IndexType.UNCOVERED_GLOBAL) { assertEquals(0, counters.findCounter(BEFORE_REBUILD_UNVERIFIED_INDEX_ROW_COUNT).getValue()); } @@ -1102,7 +1107,7 @@ public static long verifyIndexTable(String fullTableName, assertEquals(0, counters.findCounter(AFTER_REBUILD_BEYOND_MAXLOOKBACK_INVALID_INDEX_ROW_COUNT).getValue()); // Truncate, rebuild and verify the index table TableName physicalTableName = TableName.valueOf(pIndexTable.getPhysicalName().getBytes()); - PhoenixConnection pConn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pConn = conn.unwrap(PhoenixMonitoredConnection.class); try (Admin admin = pConn.getQueryServices().getAdmin()) { admin.disableTable(physicalTableName); admin.truncateTable(physicalTableName, true); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolTimeRangeIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolTimeRangeIT.java index 599b050c4cc..b5e890809bd 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolTimeRangeIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolTimeRangeIT.java @@ -30,6 +30,7 @@ import org.apache.phoenix.query.QueryServicesOptions; import org.apache.phoenix.util.EnvironmentEdge; import org.apache.phoenix.util.EnvironmentEdgeManager; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; import org.junit.AfterClass; @@ -39,8 +40,9 @@ import org.junit.experimental.categories.Category; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertFalse; - @Category(NeedsOwnMiniClusterTest.class) public class IndexToolTimeRangeIT extends BaseTest { private static final String @@ -113,8 +115,12 @@ private static void setupMiniCluster() throws Exception { clientProps.put(QueryServices.STATS_UPDATE_FREQ_MS_ATTRIB, Long.toString(5)); clientProps.put(QueryServices.TRANSACTIONS_ENABLED, Boolean.TRUE.toString()); clientProps.put(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, Boolean.TRUE.toString()); - setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), - new ReadOnlyProps(clientProps.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(serverProps.entrySet().iterator()), new ReadOnlyProps(clientProps.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), + new ReadOnlyProps(clientProps.entrySet().iterator())); + } } private int countRowsInIndex() throws SQLException { @@ -129,7 +135,7 @@ private int countRowsInIndex() throws SQLException { } private static Connection getConnection() throws SQLException { - return DriverManager.getConnection(getUrl()); + return DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); } @Test diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexUpgradeToolIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexUpgradeToolIT.java index 45ca69993a5..801b5b59378 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexUpgradeToolIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexUpgradeToolIT.java @@ -39,7 +39,6 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; - @RunWith(Parameterized.class) @Category(ParallelStatsDisabledTest.class) public class IndexUpgradeToolIT extends ParallelStatsDisabledIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexVerificationOldDesignIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexVerificationOldDesignIT.java index d26cafa0591..391e0476103 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexVerificationOldDesignIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexVerificationOldDesignIT.java @@ -40,6 +40,7 @@ import java.util.Map; import java.util.Properties; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.mapreduce.index.PhoenixIndexToolJobCounters.BEFORE_REBUILD_BEYOND_MAXLOOKBACK_MISSING_INDEX_ROW_COUNT; import static org.apache.phoenix.mapreduce.index.PhoenixIndexToolJobCounters.BEFORE_REBUILD_EXPIRED_INDEX_ROW_COUNT; import static org.apache.phoenix.mapreduce.index.PhoenixIndexToolJobCounters.BEFORE_REBUILD_INVALID_INDEX_ROW_COUNT; @@ -47,7 +48,6 @@ import static org.apache.phoenix.mapreduce.index.PhoenixIndexToolJobCounters.BEFORE_REBUILD_VALID_INDEX_ROW_COUNT; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; - @Category(NeedsOwnMiniClusterTest.class) public class IndexVerificationOldDesignIT extends BaseTest { @@ -69,8 +69,12 @@ public static synchronized void setup() throws Exception { clientProps.put(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, Boolean.TRUE.toString()); clientProps.put(QueryServices.INDEX_REGION_OBSERVER_ENABLED_ATTRIB, Boolean.toString(false)); - setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), - new ReadOnlyProps(clientProps.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(serverProps.entrySet().iterator()), new ReadOnlyProps(clientProps.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), + new ReadOnlyProps(clientProps.entrySet().iterator())); + } } @Test diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexWithDefaultValueIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexWithDefaultValueIT.java index d1827ae3d2a..2c3353097fd 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexWithDefaultValueIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexWithDefaultValueIT.java @@ -18,6 +18,7 @@ package org.apache.phoenix.end2end; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -27,10 +28,10 @@ import java.sql.ResultSet; import java.util.Properties; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertEquals; - @Category(ParallelStatsDisabledTest.class) public class IndexWithDefaultValueIT extends ParallelStatsDisabledIT { @@ -39,7 +40,7 @@ public void testQueryTableWithIndex() throws Exception { String tableName = generateUniqueName(); String indexName = generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); String schema = generateUniqueName(); Connection conn = DriverManager.getConnection(getUrl(), props); @@ -80,7 +81,7 @@ public void testQueryTableWithIndexBigintDefault() throws Exception { String tableName = generateUniqueName(); String indexName = generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); String schema = generateUniqueName(); Connection conn = DriverManager.getConnection(getUrl(), props); @@ -128,7 +129,7 @@ public void testQueryTableWithIndexDefaultValue() throws Exception { String tableName = generateUniqueName(); String indexName = generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); String schema = generateUniqueName(); Connection conn = DriverManager.getConnection(getUrl(), props); @@ -180,7 +181,7 @@ public void testDefaultLocalIndexed() throws Exception { + "c1 INTEGER," + "c2 INTEGER DEFAULT 100)"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); conn.commit(); @@ -211,7 +212,7 @@ public void testDefaultIndexed() throws Exception { + "c1 INTEGER," + "c2 INTEGER DEFAULT 100)"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); conn.commit(); @@ -242,7 +243,7 @@ public void testDefaultColumnValue() throws Exception { "pk2 INTEGER DEFAULT 10, " + "CONSTRAINT NAME_PK PRIMARY KEY (pk1))"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); String dml = "UPSERT INTO " + sharedTable1 + " VALUES (1, 1)"; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/InstrFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/InstrFunctionIT.java index b2bad7a1ec6..f1f6bf78152 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/InstrFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/InstrFunctionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +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; @@ -26,9 +27,9 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class InstrFunctionIT extends ParallelStatsDisabledIT { private void initTable(Connection conn, String tableName, String sortOrder, String s, String subStr) throws Exception { @@ -62,7 +63,7 @@ private void testInstrFilter(Connection conn, String queryToExecute, String expe @Test public void testSingleByteInstrAscending() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTable(conn, tableName, "ASC", "abcdefghijkl","fgh"); String queryToExecute = "SELECT INSTR(name, 'fgh') FROM " + tableName; @@ -71,7 +72,7 @@ public void testSingleByteInstrAscending() throws Exception { @Test public void testSingleByteInstrDescending() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTable(conn, tableName, "DESC", "abcdefghijkl","fgh"); String queryToExecute = "SELECT INSTR(name, 'fgh') FROM " + tableName; @@ -80,7 +81,7 @@ public void testSingleByteInstrDescending() throws Exception { @Test public void testSingleByteInstrAscendingNoString() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTable(conn, tableName, "ASC", "abcde fghijkl","lmn"); String queryToExecute = "SELECT INSTR(name, 'lmn') FROM " + tableName; @@ -89,7 +90,7 @@ public void testSingleByteInstrAscendingNoString() throws Exception { @Test public void testSingleByteInstrDescendingNoString() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTable(conn, tableName, "DESC", "abcde fghijkl","lmn"); String queryToExecute = "SELECT INSTR(name, 'lmn') FROM " + tableName; @@ -98,7 +99,7 @@ public void testSingleByteInstrDescendingNoString() throws Exception { @Test public void testMultiByteInstrAscending() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTable(conn, tableName, "ASC", "AɚɦFGH","ɚɦ"); String queryToExecute = "SELECT INSTR(name, 'ɚɦ') FROM " + tableName; @@ -107,7 +108,7 @@ public void testMultiByteInstrAscending() throws Exception { @Test public void testMultiByteInstrDecending() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTable(conn, tableName, "DESC", "AɚɦFGH","ɚɦ"); String queryToExecute = "SELECT INSTR(name, 'ɚɦ') FROM " + tableName; @@ -116,7 +117,7 @@ public void testMultiByteInstrDecending() throws Exception { @Test public void testByteInstrAscendingFilter() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTable(conn, tableName, "ASC", "abcdefghijkl","fgh"); String queryToExecute = "select NAME from " + tableName + " where instr(name, 'fgh') > 0"; @@ -126,7 +127,7 @@ public void testByteInstrAscendingFilter() throws Exception { @Test public void testByteInstrDecendingFilter() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTable(conn, tableName, "DESC", "abcdefghijkl","fgh"); String queryToExecute = "select NAME from " + tableName + " where instr(name, 'fgh') > 0"; @@ -135,7 +136,7 @@ public void testByteInstrDecendingFilter() throws Exception { @Test public void testNonLiteralExpression() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTable(conn, tableName, "ASC", "asdf", "sdf"); // Should be able to use INSTR with a non-literal expression as the 2nd argument @@ -145,7 +146,7 @@ public void testNonLiteralExpression() throws Exception { @Test public void testNonLiteralSourceExpression() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); initTable(conn, tableName, "ASC", "asdf", "sdf"); // Using the function inside the SELECT will test client-side. diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IntArithmeticIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IntArithmeticIT.java index 978e7bfefc1..4c3f9fee976 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IntArithmeticIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IntArithmeticIT.java @@ -44,7 +44,6 @@ import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; - @Category(ParallelStatsDisabledTest.class) @RunWith(Parameterized.class) public class IntArithmeticIT extends BaseQueryIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/InvalidateMetadataCacheIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/InvalidateMetadataCacheIT.java index b8d1d55732a..a9dddeefe1e 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/InvalidateMetadataCacheIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/InvalidateMetadataCacheIT.java @@ -34,11 +34,11 @@ import java.util.Properties; import static org.apache.hadoop.hbase.coprocessor.CoprocessorHost.REGIONSERVER_COPROCESSOR_CONF_KEY; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.query.QueryServices.PHOENIX_METADATA_CACHE_INVALIDATION_TIMEOUT_MS; import static org.apache.phoenix.query.QueryServices.PHOENIX_METADATA_INVALIDATE_CACHE_ENABLED; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.fail; - @Category({NeedsOwnMiniClusterTest.class }) public class InvalidateMetadataCacheIT extends BaseTest { private static final Logger LOGGER = LoggerFactory.getLogger(InvalidateMetadataCacheIT.class); @@ -54,7 +54,11 @@ public static synchronized void doSetup() throws Exception { FailingPhoenixRegionServerEndpoint.class.getName()); // Setting phoenix metadata cache invalidation timeout to a small number to fail fast. props.put(PHOENIX_METADATA_CACHE_INVALIDATION_TIMEOUT_MS, String.valueOf(2000)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()), new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } /** @@ -68,7 +72,7 @@ public void testAddColumnWithTimeout() { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); String dataTableFullName = generateUniqueName(); String ddl = getCreateTableStmt(dataTableFullName); - HRegionServer regionServerZero = utility.getMiniHBaseCluster().getRegionServer(0); + HRegionServer regionServerZero = getUtility().getMiniHBaseCluster().getRegionServer(0); FailingPhoenixRegionServerEndpoint coprocForRS0 = getFailingPhoenixRegionServerEndpoint(regionServerZero); coprocForRS0.sleep(); @@ -93,7 +97,7 @@ public void testAddColumnWithOneRSFailing() { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); String dataTableFullName = generateUniqueName(); String ddl = getCreateTableStmt(dataTableFullName); - HRegionServer regionServerZero = utility.getMiniHBaseCluster().getRegionServer(0); + HRegionServer regionServerZero = getUtility().getMiniHBaseCluster().getRegionServer(0); FailingPhoenixRegionServerEndpoint coprocForRS0 = getFailingPhoenixRegionServerEndpoint(regionServerZero); coprocForRS0.throwException(); @@ -118,7 +122,7 @@ public void testAddColumnWithOneRSSucceedingOnRetry() { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); String dataTableFullName = generateUniqueName(); String ddl = getCreateTableStmt(dataTableFullName); - HRegionServer regionServerZero = utility.getMiniHBaseCluster().getRegionServer(0); + HRegionServer regionServerZero = getUtility().getMiniHBaseCluster().getRegionServer(0); FailingPhoenixRegionServerEndpoint coprocForRS0 = getFailingPhoenixRegionServerEndpoint(regionServerZero); coprocForRS0.failFirstAndThenSucceed(); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IsNullIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IsNullIT.java index 22b1f37dbd0..7f05875cb5c 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IsNullIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IsNullIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +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.assertNull; @@ -27,17 +28,17 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class IsNullIT extends ParallelStatsDisabledIT { @Test public void testIsNullInPk() throws Exception { String tableName = generateUniqueName(); ensureTableCreated(getUrl(), tableName, "IntIntKeyTest"); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String upsert = "UPSERT INTO " + tableName + " VALUES(4,2)"; PreparedStatement upsertStmt = conn.prepareStatement(upsert); int rowsInserted = upsertStmt.executeUpdate(); @@ -65,7 +66,7 @@ public void testIsNullInPk() throws Exception { @Test public void testIsNullWithLastPKColDesc() throws Exception { String tableName = generateUniqueName(); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute("CREATE TABLE " + tableName + "(k1 VARCHAR NOT NULL, k2 VARCHAR, k3 VARCHAR, CONSTRAINT pk PRIMARY KEY (k1, k2, k3 DESC))"); conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES ('a')"); conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES ('b')"); @@ -90,7 +91,7 @@ public void testIsNullWithLastPKColDesc() throws Exception { @Test public void testIsNullInCompositeKey() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); conn.createStatement().execute("CREATE TABLE " + tableName + "(k1 VARCHAR, k2 VARCHAR, CONSTRAINT pk PRIMARY KEY (k1,k2))"); conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES (null,'a')"); 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 e942e3dfeaf..bdf9675bca1 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 @@ -45,7 +45,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsEnabledTest.class) public class KeyOnlyIT extends ParallelStatsEnabledIT { private String tableName; @@ -122,7 +121,7 @@ public void testKeyOnly() throws Exception { @Test public void testOr() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); initTableValues(conn); analyzeTable(conn, tableName); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LastValueFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LastValueFunctionIT.java index 448c2bc4f4e..8bc4b287e27 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LastValueFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LastValueFunctionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +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; @@ -25,16 +26,16 @@ import java.sql.DriverManager; import java.sql.ResultSet; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class LastValueFunctionIT extends ParallelStatsDisabledIT { @Test public void unsignedLong() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + "(id INTEGER NOT NULL PRIMARY KEY, page_id UNSIGNED_LONG," @@ -66,7 +67,7 @@ public void unsignedLong() throws Exception { @Test public void signedInteger() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName @@ -91,7 +92,7 @@ public void signedInteger() throws Exception { @Test public void unsignedInteger() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName @@ -116,7 +117,7 @@ public void unsignedInteger() throws Exception { @Test public void simpleTestDescOrder() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName @@ -142,7 +143,7 @@ public void simpleTestDescOrder() throws Exception { @Test public void simpleTestAscOrder() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName @@ -168,7 +169,7 @@ public void simpleTestAscOrder() throws Exception { @Test public void charDatatype() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName @@ -193,7 +194,7 @@ public void charDatatype() throws Exception { @Test public void varcharVariableLenghtDatatype() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName @@ -218,7 +219,7 @@ public void varcharVariableLenghtDatatype() throws Exception { @Test public void groupMultipleValues() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName @@ -255,7 +256,7 @@ public void groupMultipleValues() throws Exception { @Test public void nullValuesInAggregatingColumns() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName @@ -280,7 +281,7 @@ public void nullValuesInAggregatingColumns() throws Exception { @Test public void nullValuesInAggregatingColumnsSecond() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName @@ -306,7 +307,7 @@ public void nullValuesInAggregatingColumnsSecond() throws Exception { @Test public void inOrderByClausule() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LastValuesFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LastValuesFunctionIT.java index 3f504682cac..3a970518fc7 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LastValuesFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LastValuesFunctionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +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; @@ -26,17 +27,17 @@ import java.sql.ResultSet; import java.util.ArrayList; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class LastValuesFunctionIT extends ParallelStatsDisabledIT { @Test public void simpleTest() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " @@ -75,7 +76,7 @@ public void simpleTest() throws Exception { @Test public void varcharDatatypeSimpleTest() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String table_name = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + table_name + " " @@ -106,7 +107,7 @@ public void varcharDatatypeSimpleTest() throws Exception { @Test public void floatDatatypeSimpleTest() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " @@ -138,7 +139,7 @@ public void floatDatatypeSimpleTest() throws Exception { @Test public void doubleDatatypeSimpleTest() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " @@ -170,7 +171,7 @@ public void doubleDatatypeSimpleTest() throws Exception { @Test public void offsetValueAscOrder() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); @@ -204,7 +205,7 @@ public void offsetValueAscOrder() throws Exception { @Test public void simpleTestNoGroupBy() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " @@ -228,7 +229,7 @@ public void simpleTestNoGroupBy() throws Exception { @Test public void rowLessThanOffsetNoGroupBy() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " @@ -252,7 +253,7 @@ public void rowLessThanOffsetNoGroupBy() throws Exception { @Test public void offsetValueDescOrder() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " @@ -285,7 +286,7 @@ public void offsetValueDescOrder() throws Exception { @Test public void offsetValueSubAggregation() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " @@ -319,7 +320,7 @@ public void offsetValueSubAggregation() throws Exception { @Test public void offsetValueLastMismatchByColumn() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " @@ -352,7 +353,7 @@ public void offsetValueLastMismatchByColumn() throws Exception { @Test public void testSortOrderInDataColWithOffset() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " @@ -383,7 +384,7 @@ public void testSortOrderInDataColWithOffset() throws Exception { @Test public void nonUniqueValuesInOrderByAsc() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " @@ -418,7 +419,7 @@ public void nonUniqueValuesInOrderByAsc() throws Exception { @Test public void nonUniqueValuesInOrderByAscSkipDuplicit() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " @@ -455,7 +456,7 @@ public void nonUniqueValuesInOrderByAscSkipDuplicit() throws Exception { @Test public void nonUniqueValuesInOrderByDesc() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " @@ -490,7 +491,7 @@ public void nonUniqueValuesInOrderByDesc() throws Exception { @Test public void nonUniqueValuesInOrderNextValueDesc() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " @@ -526,7 +527,7 @@ public void nonUniqueValuesInOrderNextValueDesc() throws Exception { @Test public void nonUniqueValuesInOrderNextValueAsc() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " @@ -565,7 +566,7 @@ public void nonUniqueValuesInOrderNextValueAsc() throws Exception { @Test public void ignoreNullValues() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " @@ -596,7 +597,7 @@ public void ignoreNullValues() throws Exception { @Test public void rowLessThanOffsetWithGroupBy() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " " diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LikeExpressionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LikeExpressionIT.java index 9d724d16877..c71752f435f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LikeExpressionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LikeExpressionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.apache.phoenix.util.TestUtil.closeStmtAndConn; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -29,10 +30,10 @@ import java.sql.SQLException; import java.sql.Statement; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class LikeExpressionIT extends ParallelStatsDisabledIT { @@ -44,7 +45,7 @@ public void initTable() throws Exception { Connection conn = null; PreparedStatement stmt = null; try { - conn = DriverManager.getConnection(getUrl()); + conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String ddl; ddl = "CREATE TABLE " + tableName + " (k VARCHAR NOT NULL PRIMARY KEY, i INTEGER)"; conn.createStatement().execute(ddl); @@ -84,7 +85,7 @@ private void testLikeExpression(Connection conn, String likeStr, int numResult, @Test public void testLikeExpression() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); // wildcard testLikeExpression(conn, "%1%3%7%2%", 3, 7); // CaseSensitive @@ -94,7 +95,7 @@ public void testLikeExpression() throws Exception { @Test public void testLikeEverythingExpression() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String table = generateUniqueName(); String ddl = "CREATE TABLE " + table + " (k1 VARCHAR, k2 VARCHAR, CONSTRAINT pk PRIMARY KEY (k1,k2))"; @@ -153,7 +154,7 @@ public void testLikeEverythingExpression() throws Exception { @Test public void testLikeWithEscapenLParen() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String t = generateUniqueName(); String ddl = "CREATE TABLE " + t + " (k VARCHAR, v VARCHAR, CONSTRAINT pk PRIMARY KEY (k))"; conn.createStatement().execute(ddl); @@ -175,7 +176,7 @@ public void testLikeWithEscapenLParen() throws Exception { @Test public void testNewLine() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String t = generateUniqueName(); String ddl = "CREATE TABLE " + t + " (k VARCHAR NOT NULL PRIMARY KEY)"; conn.createStatement().execute(ddl); @@ -204,7 +205,7 @@ public void testNewLine() throws Exception { @Test public void testOneChar() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String t = generateUniqueName(); String ddl = "CREATE TABLE " + t + " (k VARCHAR NOT NULL PRIMARY KEY)"; conn.createStatement().execute(ddl); @@ -227,7 +228,7 @@ public void testOneChar() throws Exception { @Test public void testNull() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String table = generateUniqueName(); String ddl = "CREATE TABLE " + table + " (pk INTEGER PRIMARY KEY, str VARCHAR)"; @@ -304,7 +305,7 @@ public void testMultiCFLikeExpressionWithLimitOffset() throws Exception { "create table " + tableName + " (id integer not null primary key, cf.col1 varchar, cf.col2 varchar, cf2.col3 varchar, cf2.col4 varchar)"; String upsert = "UPSERT INTO " + tableName + " VALUES (?, ?, ?, ?, ?)"; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute(ddl); PreparedStatement stmt = conn.prepareStatement(upsert); for (int i = 1; i <= 10; i++) { @@ -364,7 +365,7 @@ public void testSingleCFLikeExpressionWithLimitOffset() throws Exception { "create table " + tableName + " (id integer not null primary key, cf.col1 varchar, cf.col2 varchar, cf.col3 varchar, cf.col4 varchar)"; String upsert = "UPSERT INTO " + tableName + " VALUES (?, ?, ?, ?, ?)"; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute(ddl); PreparedStatement stmt = conn.prepareStatement(upsert); for (int i = 1; i <= 10; i++) { @@ -419,7 +420,7 @@ public void testSingleCFLikeExpressionWithLimitOffset() throws Exception { @Test public void testParameterizedLikeExpression() throws Exception { - final Connection conn = DriverManager.getConnection(getUrl()); + final Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); final PreparedStatement select = conn.prepareStatement( "select k from " + tableName + " where k like ?"); select.setString(1, "12%"); @@ -442,7 +443,7 @@ public void testLikeExpressionWithoutWildcards() throws Exception { String likeSelect = "SELECT * FROM " + table + " WHERE USER_NAME LIKE 'Some Name'"; String iLikeSelect = "SELECT * FROM " + table + " WHERE USER_NAME ILIKE 'soMe nAme'"; - try(Connection conn = DriverManager.getConnection(getUrl())) { + try(Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.setAutoCommit(true); conn.createStatement().execute(createTable); conn.createStatement().executeUpdate(upsertTable); @@ -462,7 +463,7 @@ public void testLikeWithIndexDesc() throws Exception { String tableName = generateUniqueName(); String indexName = tableName + "_IDX"; - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.execute("CREATE TABLE " + tableName + " (id integer primary key, name varchar, type integer, status integer )"); @@ -594,7 +595,7 @@ public void testLikeWithFixedWidthIndexDesc() throws Exception { String tableName = generateUniqueName(); String indexName = tableName + "_IDX"; - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.execute("CREATE TABLE " + tableName + " (id integer primary key, name char(5), type integer, status integer )"); @@ -726,7 +727,7 @@ public void testLikeWithIndexAsc() throws Exception { String tableName = generateUniqueName(); String indexName = tableName + "_IDX"; - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.execute("CREATE TABLE " + tableName + " (id integer primary key, name varchar, type integer, status integer )"); @@ -858,7 +859,7 @@ public void testLikeWithFixedWidthIndexAsc() throws Exception { String tableName = generateUniqueName(); String indexName = tableName + "_IDX"; - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.execute("CREATE TABLE " + tableName + " (id integer primary key, name char(5), type integer, status integer )"); @@ -989,7 +990,7 @@ public void testLikeWithFixedWidthIndexAsc() throws Exception { public void testLikeWithDesc() throws Exception { String tableName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.execute("CREATE TABLE " + tableName + " (id varchar, name varchar, type decimal, " + "status integer CONSTRAINT pk PRIMARY KEY(id desc, type))"); @@ -1116,8 +1117,7 @@ public void testLikeWithDesc() throws Exception { @Test public void testLikeWithFixedWidthDesc() throws Exception { String tableName = generateUniqueName(); - - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.execute("CREATE TABLE " + tableName + " (id char(5) not null, name varchar," + " type decimal, status integer CONSTRAINT pk PRIMARY KEY(id desc, type))"); @@ -1245,7 +1245,7 @@ public void testLikeWithFixedWidthDesc() throws Exception { public void testLikeWithAsc() throws Exception { String tableName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.execute("CREATE TABLE " + tableName + " (id varchar, name varchar, type decimal, " + "status integer CONSTRAINT pk PRIMARY KEY(id, type))"); @@ -1373,7 +1373,7 @@ public void testLikeWithAsc() throws Exception { public void testLikeWithFixedWidthAsc() throws Exception { String tableName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.execute("CREATE TABLE " + tableName + " (id char(5) not null, name varchar," + " type decimal, status integer CONSTRAINT pk PRIMARY KEY(id, type))"); @@ -1502,7 +1502,7 @@ public void testLikeWithOrderByDesc() throws Exception { String tableName = generateUniqueName(); String indexName = tableName + "_IDX"; - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.execute("CREATE TABLE " + tableName + " (id integer primary key, name varchar, type integer, status integer )"); @@ -1634,7 +1634,7 @@ public void testLikeWithFixedWidthOrderByDesc() throws Exception { String tableName = generateUniqueName(); String indexName = tableName + "_IDX"; - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.execute("CREATE TABLE " + tableName + " (id integer primary key, name char(5), type integer, status integer )"); @@ -1766,7 +1766,7 @@ public void testLikeWithOrderByAsc() throws Exception { String tableName = generateUniqueName(); String indexName = tableName + "_IDX"; - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.execute("CREATE TABLE " + tableName + " (id integer primary key, name varchar, type integer, status integer)"); @@ -1898,7 +1898,7 @@ public void testLikeWithFixedWidthOrderByAsc() throws Exception { String tableName = generateUniqueName(); String indexName = tableName + "_IDX"; - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.execute("CREATE TABLE " + tableName + " (id integer primary key, name char(5), type integer, status integer)"); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LnLogFunctionEnd2EndIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LnLogFunctionEnd2EndIT.java index 4e68c9421fc..1b686406b53 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LnLogFunctionEnd2EndIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LnLogFunctionEnd2EndIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.apache.phoenix.util.TestUtil.closeStmtAndConn; import static org.junit.Assert.assertTrue; @@ -27,6 +28,7 @@ import org.apache.phoenix.expression.function.LnFunction; import org.apache.phoenix.expression.function.LogFunction; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -49,7 +51,7 @@ public void initTable() throws Exception { unsignedTableName = generateUniqueName(); try { - conn = DriverManager.getConnection(getUrl()); + conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String ddl; ddl = "CREATE TABLE " + signedTableName + " (k VARCHAR NOT NULL PRIMARY KEY, doub DOUBLE, fl FLOAT, inte INTEGER, lon BIGINT, smalli SMALLINT, tinyi TINYINT)"; @@ -125,7 +127,7 @@ private void testNumberSpec(Connection conn, double data, String tableName) thro @Test public void test() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); for (double d : new double[] { 0.0, 1.0, -1.0, 123.1234, -123.1234 }) { testNumberSpec(conn, d, signedTableName ); if (d >= 0) testNumberSpec(conn, d, unsignedTableName ); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LocalIndexSplitMergeIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LocalIndexSplitMergeIT.java index 07e4e731c5b..d2bf1a26341 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LocalIndexSplitMergeIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LocalIndexSplitMergeIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -37,6 +38,7 @@ import org.apache.phoenix.compile.ExplainPlan; import org.apache.phoenix.compile.ExplainPlanAttributes; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixPreparedStatement; import org.apache.phoenix.query.BaseTest; import org.apache.phoenix.query.QueryServices; @@ -51,7 +53,6 @@ import org.junit.experimental.categories.Category; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; - @Category(NeedsOwnMiniClusterTest.class) public class LocalIndexSplitMergeIT extends BaseTest { @@ -63,8 +64,12 @@ public static synchronized void doSetup() throws Exception { Map clientProps = Maps.newHashMapWithExpectedSize(2); clientProps.put(QueryServices.TRANSACTIONS_ENABLED, Boolean.TRUE.toString()); clientProps.put(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, Boolean.TRUE.toString()); - setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), - new ReadOnlyProps(clientProps.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(serverProps.entrySet().iterator()), new ReadOnlyProps(clientProps.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), + new ReadOnlyProps(clientProps.entrySet().iterator())); + } } private Connection getConnectionForLocalIndexTest() throws SQLException { @@ -114,7 +119,7 @@ public void testLocalIndexScanAfterRegionSplit() throws Exception { ResultSet rs = conn1.createStatement().executeQuery("SELECT * FROM " + tableName); assertTrue(rs.next()); - Admin admin = conn1.unwrap(PhoenixConnection.class).getQueryServices().getAdmin(); + Admin admin = conn1.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin(); for (int i = 1; i < 3; i++) { admin.split(physicalTableName, ByteUtil.concat(Bytes.toBytes(strings[3 * i]))); List regionsOfUserTable = @@ -239,7 +244,7 @@ public void testLocalIndexScanAfterRegionsMerge() throws Exception { ResultSet rs = conn1.createStatement().executeQuery("SELECT * FROM " + tableName); assertTrue(rs.next()); - Admin admin = conn1.unwrap(PhoenixConnection.class).getQueryServices().getAdmin(); + Admin admin = conn1.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin(); List regionsOfUserTable = MetaTableAccessor.getTableRegions(admin.getConnection(), physicalTableName, false); @@ -335,7 +340,7 @@ public void testLocalIndexScanWithMergeSpecialCase() throws Exception { conn1.createStatement() .execute("CREATE LOCAL INDEX " + indexName + "_2 ON " + tableName + "(k3)"); - Admin admin = conn1.unwrap(PhoenixConnection.class).getQueryServices().getAdmin(); + Admin admin = conn1.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin(); List regionsOfUserTable = MetaTableAccessor.getTableRegions(admin.getConnection(), physicalTableName, false); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LogicalTableNameBaseIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LogicalTableNameBaseIT.java index bae0589b681..70a327b90e3 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LogicalTableNameBaseIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LogicalTableNameBaseIT.java @@ -24,6 +24,7 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.coprocessorclient.BaseScannerRegionObserverConstants; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.BaseTest; import org.apache.phoenix.query.PhoenixTestBuilder; import org.apache.phoenix.query.QueryConstants; @@ -56,6 +57,7 @@ import java.util.Random; import static java.util.Arrays.asList; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.query.PhoenixTestBuilder.DDLDefaults.MAX_ROWS; import static org.apache.phoenix.query.QueryConstants.NAMESPACE_SEPARATOR; import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB; @@ -65,7 +67,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; - public abstract class LogicalTableNameBaseIT extends BaseTest { protected String dataTableDdl = ""; public static final String NEW_TABLE_PREFIX = "NEW_TBL_"; @@ -78,7 +79,11 @@ static void initCluster(boolean isNamespaceMapped) throws Exception { if (isNamespaceMapped) { props.put(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.TRUE.toString()); } - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()), new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } protected Connection getConnection(Properties props) throws Exception { @@ -87,7 +92,7 @@ protected Connection getConnection(Properties props) throws Exception { // more than one ConnectionQueryService props.setProperty(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, StringUtil.EMPTY_STRING); // Create new ConnectionQueryServices so that we can set DROP_METADATA_ATTRIB - String url = QueryUtil.getConnectionUrl(props, config, "PRINCIPAL"); + String url = QueryUtil.getConnectionUrl(props, getConfiguration(), "PRINCIPAL"); return DriverManager.getConnection(url, props); } @@ -105,7 +110,7 @@ public static void createAndPointToNewPhysicalTable(Connection conn, String full snapshotName = new StringBuilder(tableName).append("-Snapshot").toString(); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices() + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices() .getAdmin()) { admin.snapshot(snapshotName, TableName.valueOf(fullTableHName)); @@ -132,12 +137,12 @@ protected HashMap> testBaseTableWithIndex_BaseTableCha // Create another hbase table and add 1 more row String newTableName = NEW_TABLE_PREFIX + tableName; String fullNewTableName = SchemaUtil.getTableName(schemaName, newTableName); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { String snapshotName = new StringBuilder(fullTableName).append("-Snapshot").toString(); admin.snapshot(snapshotName, TableName.valueOf(fullTableName)); admin.cloneSnapshot(snapshotName, TableName.valueOf(fullNewTableName)); admin.deleteSnapshot(snapshotName); - try (Table htable = conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(Bytes.toBytes(fullNewTableName))) { + try (Table htable = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getTable(Bytes.toBytes(fullNewTableName))) { Put put = new Put(ByteUtil.concat(Bytes.toBytes("PK3"))); put.addColumn(QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES, QueryConstants.EMPTY_COLUMN_BYTES, QueryConstants.EMPTY_COLUMN_VALUE_BYTES); @@ -184,13 +189,13 @@ protected HashMap> test_IndexTableChange(Connection co fullNewTableName = schemaName + NAMESPACE_SEPARATOR + newTableName; fullIndexTableHbaseName = schemaName + NAMESPACE_SEPARATOR + indexName; } - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices() + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices() .getAdmin()) { String snapshotName = new StringBuilder(indexName).append("-Snapshot").toString(); admin.snapshot(snapshotName, TableName.valueOf(fullIndexTableHbaseName)); admin.cloneSnapshot(snapshotName, TableName.valueOf(fullNewTableName)); admin.deleteSnapshot(snapshotName); - try (Table htable = conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(Bytes.toBytes(fullNewTableName))) { + try (Table htable = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getTable(Bytes.toBytes(fullNewTableName))) { Put put = new Put(ByteUtil.concat(Bytes.toBytes("V13"), QueryConstants.SEPARATOR_BYTE_ARRAY, Bytes.toBytes("PK3"))); @@ -243,13 +248,13 @@ protected HashMap> testWithViewsAndIndex_BaseTableChan fullNewTableName = schemaName + NAMESPACE_SEPARATOR + newTableName; fullTableHbaseName = schemaName + NAMESPACE_SEPARATOR + tableName; } - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices() + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices() .getAdmin()) { String snapshotName = new StringBuilder(fullTableName).append("-Snapshot").toString(); admin.snapshot(snapshotName, TableName.valueOf(fullTableHbaseName)); admin.cloneSnapshot(snapshotName, TableName.valueOf(fullNewTableName)); admin.deleteSnapshot(snapshotName); - try (Table htable = conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(Bytes.toBytes(fullNewTableName))) { + try (Table htable = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getTable(Bytes.toBytes(fullNewTableName))) { Put put = new Put(ByteUtil.concat(Bytes.toBytes("PK3"))); put.addColumn(QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES, QueryConstants.EMPTY_COLUMN_BYTES, QueryConstants.EMPTY_COLUMN_VALUE_BYTES); @@ -280,7 +285,7 @@ protected HashMap> testWithViewsAndIndex_BaseTableChan // Rename table to point to hbase table renameAndDropPhysicalTable(conn, "NULL", schemaName, tableName, newTableName, isNamespaceEnabled); - conn.unwrap(PhoenixConnection.class).getQueryServices().clearCache(); + conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().clearCache(); if (createChildAfterRename) { createViewAndIndex(conn2, schemaName, tableName, viewName1, v1_indexName1); createViewAndIndex(conn2, schemaName, tableName, viewName1, v1_indexName2); @@ -382,7 +387,7 @@ protected PhoenixTestBuilder.SchemaBuilder testGlobalViewAndTenantView(boolean c String tenantConnectUrl = getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(); - try (Connection tenantConnection = DriverManager.getConnection(tenantConnectUrl)) { + try (Connection tenantConnection = DriverManager.getConnection(tenantConnectUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { tenantConnection.setAutoCommit(true); dataWriter.setConnection(tenantConnection); dataWriter.setDataSupplier(dataSupplier); @@ -545,11 +550,11 @@ public static void renameAndDropPhysicalTable(Connection conn, String tenantId, if (isNamespaceEnabled && !(Strings.isNullOrEmpty(schema) || NULL_STRING.equals(schema))) { fullTableName = schema + NAMESPACE_SEPARATOR + tableName; } - Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin(); + Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin(); TableName hTableName = TableName.valueOf(fullTableName); admin.disableTable(hTableName); admin.deleteTable(hTableName); - conn.unwrap(PhoenixConnection.class).getQueryServices() + conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices() .clearCache(); } } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LogicalTableNameExtendedIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LogicalTableNameExtendedIT.java index b99f66d1ca0..cc4868ca201 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LogicalTableNameExtendedIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LogicalTableNameExtendedIT.java @@ -25,6 +25,7 @@ import org.apache.phoenix.end2end.index.SingleCellIndexIT; import org.apache.phoenix.hbase.index.IndexRegionObserver; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.QueryConstants; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.types.PInteger; @@ -44,7 +45,6 @@ import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; - @Category(NeedsOwnMiniClusterTest.class) public class LogicalTableNameExtendedIT extends LogicalTableNameBaseIT { private Properties propsNamespace = PropertiesUtil.deepCopy(TEST_PROPERTIES); @@ -95,7 +95,7 @@ private void test_bothTableAndIndexHaveDifferentNames(Connection conn, Connectio QueryConstants.UNVERIFIED_BYTES, true); // Now change physical data table createAndPointToNewPhysicalTable(conn, fullTableHName, true); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices() + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices() .getAdmin()) { assertEquals(false, admin.tableExists(TableName.valueOf(fullTableHName))); assertEquals(false, admin.tableExists(TableName.valueOf(fullIndexHName))); @@ -115,7 +115,7 @@ public void testUpdatePhysicalTableName_bothTableAndIndexHaveDifferentNames() th try (Connection conn = getConnection(propsNamespace)) { try (Connection conn2 = getConnection(propsNamespace)) { test_bothTableAndIndexHaveDifferentNames(conn, conn2, schemaName, tableName, indexName); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices() + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices() .getAdmin()) { conn2.setAutoCommit(true); // Add row and check diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LogicalTableNameIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LogicalTableNameIT.java index 542176e0846..4c78538dd40 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LogicalTableNameIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LogicalTableNameIT.java @@ -55,7 +55,6 @@ import static org.apache.phoenix.util.MetaDataUtil.VIEW_INDEX_TABLE_PREFIX; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.*; - @RunWith(Parameterized.class) @Category(NeedsOwnMiniClusterTest.class) public class LogicalTableNameIT extends LogicalTableNameBaseIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LongViewIndexDisabledBaseRowKeyMatcherIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LongViewIndexDisabledBaseRowKeyMatcherIT.java index a01159f68cc..4113332024f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LongViewIndexDisabledBaseRowKeyMatcherIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LongViewIndexDisabledBaseRowKeyMatcherIT.java @@ -24,6 +24,7 @@ import org.apache.phoenix.query.ConfigurationFactory; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.util.InstanceResolver; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.junit.BeforeClass; import org.junit.experimental.categories.Category; @@ -34,8 +35,9 @@ import java.util.HashMap; import java.util.Map; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.query.QueryServices.SYSTEM_CATALOG_INDEXES_ENABLED; - +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; @Category(NeedsOwnMiniClusterTest.class) public class LongViewIndexDisabledBaseRowKeyMatcherIT extends BaseRowKeyMatcherTestIT { @@ -71,12 +73,18 @@ public Configuration getConfiguration(Configuration confToClone) { put(QueryServices.LONG_VIEW_INDEX_ENABLED_ATTRIB, String.valueOf(false)); }}; - setUpTestDriver(new ReadOnlyProps(ReadOnlyProps.EMPTY_PROPS, - DEFAULT_PROPERTIES.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(ReadOnlyProps.EMPTY_PROPS, + DEFAULT_PROPERTIES.entrySet().iterator()),new ReadOnlyProps(ReadOnlyProps.EMPTY_PROPS, + DEFAULT_PROPERTIES.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(ReadOnlyProps.EMPTY_PROPS, + DEFAULT_PROPERTIES.entrySet().iterator())); + } // Create the CATALOG indexes for additional verifications using the catalog indexes - try (Connection conn = DriverManager.getConnection(getUrl()); - Statement stmt = conn.createStatement()) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Statement stmt = conn.createStatement()) { //TestUtil.dumpTable(conn, TableName.valueOf(PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME_BYTES)); stmt.execute("CREATE INDEX IF NOT EXISTS SYS_VIEW_HDR_IDX ON SYSTEM.CATALOG(TENANT_ID, TABLE_SCHEM, TABLE_NAME, COLUMN_NAME, COLUMN_FAMILY) INCLUDE (TABLE_TYPE, VIEW_STATEMENT, TTL, ROW_KEY_MATCHER) WHERE TABLE_TYPE = 'v'"); stmt.execute("CREATE INDEX IF NOT EXISTS SYS_ROW_KEY_MATCHER_IDX ON SYSTEM.CATALOG(ROW_KEY_MATCHER, TTL, TABLE_TYPE, TENANT_ID, TABLE_SCHEM, TABLE_NAME) INCLUDE (VIEW_STATEMENT) WHERE TABLE_TYPE = 'v' AND ROW_KEY_MATCHER IS NOT NULL"); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LongViewIndexEnabledBaseRowKeyMatcherIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LongViewIndexEnabledBaseRowKeyMatcherIT.java index 3d73c948ba2..0306de02ee6 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LongViewIndexEnabledBaseRowKeyMatcherIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LongViewIndexEnabledBaseRowKeyMatcherIT.java @@ -25,6 +25,7 @@ import org.apache.phoenix.query.ConfigurationFactory; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.util.InstanceResolver; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.junit.BeforeClass; import org.junit.experimental.categories.Category; @@ -35,8 +36,9 @@ import java.util.HashMap; import java.util.Map; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.query.QueryServices.SYSTEM_CATALOG_INDEXES_ENABLED; - +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; @Category(NeedsOwnMiniClusterTest.class) public class LongViewIndexEnabledBaseRowKeyMatcherIT extends BaseRowKeyMatcherTestIT { @@ -72,12 +74,18 @@ public Configuration getConfiguration(Configuration confToClone) { put(QueryServices.LONG_VIEW_INDEX_ENABLED_ATTRIB, String.valueOf(true)); }}; - setUpTestDriver(new ReadOnlyProps(ReadOnlyProps.EMPTY_PROPS, - DEFAULT_PROPERTIES.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(ReadOnlyProps.EMPTY_PROPS, + DEFAULT_PROPERTIES.entrySet().iterator()),new ReadOnlyProps(ReadOnlyProps.EMPTY_PROPS, + DEFAULT_PROPERTIES.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(ReadOnlyProps.EMPTY_PROPS, + DEFAULT_PROPERTIES.entrySet().iterator())); + } // Create the CATALOG indexes for additional verifications using the catalog indexes - try (Connection conn = DriverManager.getConnection(getUrl()); - Statement stmt = conn.createStatement()) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Statement stmt = conn.createStatement()) { //TestUtil.dumpTable(conn, TableName.valueOf(PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME_BYTES)); stmt.execute("CREATE INDEX IF NOT EXISTS SYS_VIEW_HDR_IDX ON SYSTEM.CATALOG(TENANT_ID, TABLE_SCHEM, TABLE_NAME, COLUMN_NAME, COLUMN_FAMILY) INCLUDE (TABLE_TYPE, VIEW_STATEMENT, TTL, ROW_KEY_MATCHER) WHERE TABLE_TYPE = 'v'"); stmt.execute("CREATE INDEX IF NOT EXISTS SYS_ROW_KEY_MATCHER_IDX ON SYSTEM.CATALOG(ROW_KEY_MATCHER, TTL, TABLE_TYPE, TENANT_ID, TABLE_SCHEM, TABLE_NAME) INCLUDE (VIEW_STATEMENT) WHERE TABLE_TYPE = 'v' AND ROW_KEY_MATCHER IS NOT NULL"); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MD5FunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MD5FunctionIT.java index 15d9cac0d0e..0360fb30eba 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MD5FunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MD5FunctionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -27,18 +28,17 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class MD5FunctionIT extends ParallelStatsDisabledIT { @Test public void testRetrieve() throws Exception { String testString = "mwalsh"; - - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String md5_retrieve_test = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + md5_retrieve_test + " (pk VARCHAR NOT NULL PRIMARY KEY)"; @@ -81,8 +81,8 @@ public void testRetrieveCompositeKey() throws Exception { public void testUpsert() throws Exception { String testString1 = "mwalsh1"; String testString2 = "mwalsh2"; - - Connection conn = DriverManager.getConnection(getUrl()); + + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String md5_upsert_test = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + md5_upsert_test + " (k1 binary(16) NOT NULL,k2 binary(16) NOT NULL CONSTRAINT pk PRIMARY KEY (k1, k2))"; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MapReduceIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MapReduceIT.java index 0631ddf6e6e..ca87015ce69 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MapReduceIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MapReduceIT.java @@ -34,6 +34,7 @@ import org.apache.phoenix.schema.types.PDouble; import org.apache.phoenix.schema.types.PhoenixArray; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -49,6 +50,7 @@ import java.sql.SQLTimeoutException; import java.util.Properties; +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; @@ -97,49 +99,49 @@ public void clearCountersForScanGrouper() throws Exception { @Test public void testNoConditionsOnSelect() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { createAndTestJob(conn, null, 91.04, null); } } @Test public void testConditionsOnSelect() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { createAndTestJob(conn, RECORDING_YEAR + " < 2009", 81.04, null); } } @Test public void testMapReduceWithVerySmallPhoenixQueryTimeout() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { createPagedJobAndTestFailedJobDueToTimeOut(conn, RECORDING_YEAR + " % 2 = 0", 82.89, null, true); } } @Test public void testMapReduceWithVerySmallPhoenixQueryTimeoutWithTenantId() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { createPagedJobAndTestFailedJobDueToTimeOut(conn, RECORDING_YEAR + " % 2 = 0", 82.89, TENANT_ID, true); } } @Test public void testMapReduceWithNormalPhoenixQueryTimeout() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { createPagedJobAndTestFailedJobDueToTimeOut(conn, RECORDING_YEAR + " % 2 = 0", 82.89, null, false); } } @Test public void testMapReduceWithNormalPhoenixQueryTimeoutWithTenantId() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { createPagedJobAndTestFailedJobDueToTimeOut(conn, RECORDING_YEAR + " % 2 = 0", 81.04, TENANT_ID, false); } } @Test public void testWithTenantId() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())){ + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { //tenant view will perform the same filter as the select conditions do in testConditionsOnSelect createAndTestJob(conn, null, 81.04, TENANT_ID); } @@ -222,7 +224,7 @@ private void createPagedJobAndTestFailedJobDueToTimeOut(Connection conn, String assertTrue("Job didn't complete successfully! Check logs for reason.", job.waitForCompletion(true)); //verify - ResultSet stats = DriverManager.getConnection(getUrl()).createStatement() + ResultSet stats = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).createStatement() .executeQuery("SELECT * FROM " + stockStatsTableName); assertTrue("No data stored in stats table!", stats.next()); String name = stats.getString(1); @@ -238,7 +240,7 @@ private void createPagedJobAndTestFailedJobDueToTimeOut(Connection conn, String } private void setInputForTenant(Job job, String tenantId, String stockTableName, String s) throws SQLException { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, TENANT_ID); try (Connection tenantConn = DriverManager.getConnection(getUrl(), props)){ PhoenixMapReduceUtil.setTenantId(job, tenantId); @@ -273,7 +275,7 @@ private void testJob(Connection conn, Job job, String stockTableName, String sto assertTrue("Job didn't complete successfully! Check logs for reason.", job.waitForCompletion(true)); // verify - ResultSet stats = DriverManager.getConnection(getUrl()).createStatement() + ResultSet stats = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).createStatement() .executeQuery("SELECT * FROM " + stockStatsTableName); assertTrue("No data stored in stats table!", stats.next()); String name = stats.getString(1); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MappingTableDataTypeIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MappingTableDataTypeIT.java index 8527c69fba9..086cc023ce5 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MappingTableDataTypeIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MappingTableDataTypeIT.java @@ -44,12 +44,11 @@ import org.apache.hadoop.hbase.client.Table; import org.apache.hadoop.hbase.client.TableDescriptorBuilder; import org.apache.hadoop.hbase.util.Bytes; -import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class MappingTableDataTypeIT extends ParallelStatsDisabledIT { @Test @@ -57,7 +56,7 @@ public void testMappingHbaseTableToPhoenixTable() throws Exception { String mtest = generateUniqueName(); final TableName tableName = TableName.valueOf(mtest); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - PhoenixConnection conn = DriverManager.getConnection(getUrl(), props).unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection conn = DriverManager.getConnection(getUrl(), props).unwrap(PhoenixMonitoredConnection.class); try(Table t = conn.getQueryServices().getTable(Bytes.toBytes(mtest)); Admin admin = conn.getQueryServices().getAdmin()) { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MathPIFunctionEnd2EndIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MathPIFunctionEnd2EndIT.java index 759f8c85e37..cb0bfa9c9d0 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MathPIFunctionEnd2EndIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MathPIFunctionEnd2EndIT.java @@ -17,12 +17,14 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.*; import java.sql.*; import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.expression.function.MathPIFunction; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -35,7 +37,7 @@ public class MathPIFunctionEnd2EndIT extends ParallelStatsDisabledIT { @Test public void testGetMathPIValue() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery("SELECT PI()"); assertTrue(rs.next()); assertTrue(twoDoubleEquals(rs.getDouble(1), Math.PI)); @@ -44,7 +46,7 @@ public void testGetMathPIValue() throws Exception { @Test public void testMathPIRoundTwoDecimal() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery("SELECT ROUND(PI(), 2)"); assertTrue(rs.next()); assertTrue(twoDoubleEquals(rs.getDouble(1), 3.14)); @@ -53,7 +55,7 @@ public void testMathPIRoundTwoDecimal() throws Exception { @Test public void testMathPIFunctionWithIncorrectFormat() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { conn.createStatement().executeQuery("SELECT PI(1)"); } catch (SQLException e) { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MathTrigFunctionEnd2EndIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MathTrigFunctionEnd2EndIT.java index a5daee16bea..9945c21d690 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MathTrigFunctionEnd2EndIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MathTrigFunctionEnd2EndIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.apache.phoenix.util.TestUtil.closeStmtAndConn; import static org.junit.Assert.assertTrue; @@ -28,6 +29,7 @@ import org.apache.phoenix.expression.function.CosFunction; import org.apache.phoenix.expression.function.SinFunction; import org.apache.phoenix.expression.function.TanFunction; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -38,7 +40,6 @@ * {@link org.apache.phoenix.expression.function.SinFunction} * {@link org.apache.phoenix.expression.function.TanFunction} */ - @Category(ParallelStatsDisabledTest.class) public class MathTrigFunctionEnd2EndIT extends ParallelStatsDisabledIT { @@ -52,7 +53,7 @@ public void initTable() throws Exception { tableName = generateUniqueName(); try { - conn = DriverManager.getConnection(getUrl()); + conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String ddl; ddl = "CREATE TABLE " + tableName + " (k VARCHAR NOT NULL PRIMARY KEY, doub DOUBLE)"; @@ -88,7 +89,7 @@ private void testNumberSpec(Connection conn, double data, String tableName) thro @Test public void test() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)); for (double d : new double[] { 0.0, 1.0, -1.0, 123.1234, -123.1234 }) { testNumberSpec(conn, d, tableName); } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MaxLookbackExtendedIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MaxLookbackExtendedIT.java index c66cb1a03a0..a756aec8efb 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MaxLookbackExtendedIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MaxLookbackExtendedIT.java @@ -33,6 +33,7 @@ import org.apache.phoenix.util.EnvironmentEdgeManager; import org.apache.phoenix.util.ManualEnvironmentEdge; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.QueryUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; @@ -57,16 +58,17 @@ import java.util.Map; import java.util.Properties; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.util.TestUtil.assertRawCellCount; import static org.apache.phoenix.util.TestUtil.assertRawRowCount; import static org.apache.phoenix.util.TestUtil.assertRowExistsAtSCN; import static org.apache.phoenix.util.TestUtil.assertRowHasExpectedValueAtSCN; import static org.apache.phoenix.util.TestUtil.assertTableHasVersions; +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.assertNotNull; import static org.junit.Assert.assertTrue; - @Category(NeedsOwnMiniClusterTest.class) @RunWith(Parameterized.class) public class MaxLookbackExtendedIT extends BaseTest { @@ -89,7 +91,11 @@ public static synchronized void doSetup() throws Exception { props.put(BaseScannerRegionObserverConstants.PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY, Integer.toString(MAX_LOOKBACK_AGE)); props.put("hbase.procedure.remote.dispatcher.delay.msec", "0"); props.put(HRegion.MEMSTORE_PERIODIC_FLUSH_INTERVAL, "0"); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()), new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @Before @@ -121,7 +127,7 @@ public void testKeepDeletedCellsWithMaxLookbackAge() throws Exception { optionBuilder.append(", VERSIONS=" + versions); optionBuilder.append(", KEEP_DELETED_CELLS=TRUE"); tableDDLOptions = optionBuilder.toString(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String dataTableName = generateUniqueName(); createTable(dataTableName); injectEdge.setValue(System.currentTimeMillis()); @@ -208,7 +214,7 @@ public void testTooLowSCNWithMaxLookbackAge() throws Exception { populateTable(dataTableName); long populateTime = EnvironmentEdgeManager.currentTimeMillis(); injectEdge.incrementValue(MAX_LOOKBACK_AGE * 1000 + 1000); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(populateTime)); try (Connection connscn = DriverManager.getConnection(getUrl(), props)) { @@ -224,7 +230,7 @@ public void testTooLowSCNWithMaxLookbackAge() throws Exception { @Test(timeout=120000L) public void testRecentlyDeletedRowsNotCompactedAway() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String dataTableName = generateUniqueName(); String indexName = generateUniqueName(); createTable(dataTableName); @@ -301,7 +307,7 @@ public void testViewIndexIsCompacted() throws Exception { String globalViewIdx = generateUniqueName(); TableName dataTable = TableName.valueOf(baseTable); TableName indexTable = TableName.valueOf("_IDX_" + baseTable); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute("CREATE TABLE " + baseTable + " (TENANT_ID CHAR(15) NOT NULL, PK2 INTEGER NOT NULL, PK3 INTEGER NOT NULL, " + "COL1 VARCHAR, COL2 VARCHAR, COL3 CHAR(15) CONSTRAINT PK PRIMARY KEY" @@ -357,7 +363,7 @@ public void testTTLAndMaxLookbackAge() throws Exception { long oldMemstoreFlushInterval = conf.getLong(HRegion.MEMSTORE_PERIODIC_FLUSH_INTERVAL, HRegion.DEFAULT_CACHE_FLUSH_INTERVAL); conf.setLong(HRegion.MEMSTORE_PERIODIC_FLUSH_INTERVAL, 0L); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String dataTableName = generateUniqueName(); String indexName = generateUniqueName(); createTable(dataTableName); @@ -438,7 +444,7 @@ public void testRecentMaxVersionsNotCompactedAway() throws Exception { String firstValue = "abc"; String secondValue = "def"; String thirdValue = "ghi"; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String dataTableName = generateUniqueName(); String indexName = generateUniqueName(); createTable(dataTableName); @@ -510,7 +516,7 @@ public void testRecentMaxVersionsNotCompactedAway() throws Exception { @Test(timeout=60000) public void testOverrideMaxLookbackForCompaction() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tableNameOne = generateUniqueName(); createTable(tableNameOne); String tableNameTwo = generateUniqueName(); @@ -566,7 +572,7 @@ public void testOverrideMaxLookbackForCompaction() throws Exception { @Test(timeout=60000) public void testRetainingLastRowVersion() throws Exception { - try(Connection conn = DriverManager.getConnection(getUrl())) { + try(Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tableName = generateUniqueName(); createTable(tableName); long timeIntervalBetweenTwoUpserts = (ttl / 4) + 1; @@ -590,7 +596,7 @@ public void testRetainingLastRowVersion() throws Exception { injectEdge.incrementValue(timeIntervalBetweenTwoUpserts * 1000); flush(dataTableName); injectEdge.incrementValue(1); - TestUtil.minorCompact(utility, dataTableName); + TestUtil.minorCompact(getUtility(), dataTableName); injectEdge.incrementValue(1); stmt.execute("upsert into " + tableName + " values ('a', 'ab3')"); conn.commit(); @@ -603,7 +609,7 @@ public void testRetainingLastRowVersion() throws Exception { flush(dataTableName); TestUtil.dumpTable(conn, dataTableName); injectEdge.incrementValue(1); - TestUtil.minorCompact(utility, dataTableName); + TestUtil.minorCompact(getUtility(), dataTableName); injectEdge.incrementValue(MAX_LOOKBACK_AGE * 1000 - 1); TestUtil.dumpTable(conn, dataTableName); majorCompact(dataTableName); @@ -645,7 +651,7 @@ private void updateColumn(Connection conn, String dataTableName, } private void createTable(String tableName) throws SQLException { - try(Connection conn = DriverManager.getConnection(getUrl())) { + try(Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String createSql; if (multiCF) { createSql = "create table " + tableName + @@ -662,7 +668,7 @@ private void createTable(String tableName) throws SQLException { } } private void populateTable(String tableName) throws SQLException { - try(Connection conn = DriverManager.getConnection(getUrl())) { + try(Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute("upsert into " + tableName + " values ('a', 'ab', 'abc', 'abcd')"); conn.commit(); conn.createStatement().execute("upsert into " + tableName + " values ('b', 'bc', 'bcd', 'bcde')"); @@ -672,7 +678,7 @@ private void populateTable(String tableName) throws SQLException { private void createIndex(String dataTableName, String indexTableName, int indexVersions) throws SQLException { - try(Connection conn = DriverManager.getConnection(getUrl())) { + try(Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute("CREATE INDEX " + indexTableName + " on " + dataTableName + " (val1) include (val2, val3)" + " VERSIONS=" + indexVersions); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MaxLookbackIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MaxLookbackIT.java index b77965d74cc..ac5fb416f28 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MaxLookbackIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MaxLookbackIT.java @@ -29,6 +29,7 @@ import org.apache.phoenix.util.EnvironmentEdgeManager; import org.apache.phoenix.util.ManualEnvironmentEdge; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.QueryUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.TestUtil; @@ -49,13 +50,14 @@ import java.util.Properties; import static org.apache.phoenix.coprocessorclient.BaseScannerRegionObserverConstants.PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.util.TestUtil.assertRawCellCount; import static org.apache.phoenix.util.TestUtil.assertRawRowCount; import static org.apache.phoenix.util.TestUtil.assertRowExistsAtSCN; import static org.apache.phoenix.util.TestUtil.assertRowHasExpectedValueAtSCN; import static org.apache.phoenix.util.TestUtil.assertTableHasVersions; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertFalse; - @Category(NeedsOwnMiniClusterTest.class) public class MaxLookbackIT extends BaseTest { private static final int MAX_LOOKBACK_AGE = 15; @@ -73,7 +75,11 @@ public static synchronized void doSetup() throws Exception { props.put(PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY, Integer.toString(MAX_LOOKBACK_AGE)); props.put(QueryServices.PHOENIX_COMPACTION_ENABLED, Boolean.toString(false)); props.put("hbase.procedure.remote.dispatcher.delay.msec", "0"); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()), new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @Before @@ -105,7 +111,7 @@ public void testTooLowSCNWithMaxLookbackAge() throws Exception { populateTable(dataTableName); long populateTime = EnvironmentEdgeManager.currentTimeMillis(); injectEdge.incrementValue(MAX_LOOKBACK_AGE * 1000 + 1000); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(populateTime)); try (Connection connscn = DriverManager.getConnection(getUrl(), props)) { @@ -121,7 +127,7 @@ public void testTooLowSCNWithMaxLookbackAge() throws Exception { @Test(timeout=120000L) public void testRecentlyDeletedRowsNotCompactedAway() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String dataTableName = generateUniqueName(); String indexName = generateUniqueName(); createTable(dataTableName); @@ -196,7 +202,7 @@ public void testTTLAndMaxLookbackAge() throws Exception { long oldMemstoreFlushInterval = conf.getLong(HRegion.MEMSTORE_PERIODIC_FLUSH_INTERVAL, HRegion.DEFAULT_CACHE_FLUSH_INTERVAL); conf.setLong(HRegion.MEMSTORE_PERIODIC_FLUSH_INTERVAL, 0L); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String dataTableName = generateUniqueName(); String indexName = generateUniqueName(); createTable(dataTableName); @@ -266,7 +272,7 @@ public void testRecentMaxVersionsNotCompactedAway() throws Exception { String firstValue = "abc"; String secondValue = "def"; String thirdValue = "ghi"; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String dataTableName = generateUniqueName(); String indexName = generateUniqueName(); createTable(dataTableName); @@ -363,7 +369,7 @@ private void updateColumn(Connection conn, String dataTableName, } private void createTable(String tableName) throws SQLException { - try(Connection conn = DriverManager.getConnection(getUrl())) { + try(Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String createSql = "create table " + tableName + " (id varchar(10) not null primary key, val1 varchar(10), " + "val2 varchar(10), val3 varchar(10))" + tableDDLOptions; @@ -372,7 +378,7 @@ private void createTable(String tableName) throws SQLException { } } private void populateTable(String tableName) throws SQLException { - try(Connection conn = DriverManager.getConnection(getUrl())) { + try(Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute("upsert into " + tableName + " values ('a', 'ab', 'abc', 'abcd')"); conn.commit(); conn.createStatement().execute("upsert into " + tableName + " values ('b', 'bc', 'bcd', 'bcde')"); @@ -382,7 +388,7 @@ private void populateTable(String tableName) throws SQLException { private void createIndex(String dataTableName, String indexTableName, int indexVersions) throws SQLException { - try(Connection conn = DriverManager.getConnection(getUrl())) { + try(Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute("CREATE INDEX " + indexTableName + " on " + dataTableName + " (val1) include (val2, val3)" + " VERSIONS=" + indexVersions); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MergeViewIndexIdSequencesToolIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MergeViewIndexIdSequencesToolIT.java index a74fed591a4..11fd91a5979 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MergeViewIndexIdSequencesToolIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MergeViewIndexIdSequencesToolIT.java @@ -18,6 +18,7 @@ package org.apache.phoenix.end2end; import org.apache.phoenix.util.MergeViewIndexIdSequencesTool; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -28,7 +29,7 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertTrue; - +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; @Category(NeedsOwnMiniClusterTest.class) public class MergeViewIndexIdSequencesToolIT extends ParallelStatsDisabledIT { private final String CLEAN_QUERY = "DELETE FROM SYSTEM.\"SEQUENCE\""; @@ -55,8 +56,8 @@ public void testNewSequenceFormat() throws Exception { private void testSequenceRowCount(boolean isTestingOldFormat) throws Exception { int expectedRowCount = isTestingOldFormat ? 2 : 1; MergeViewIndexIdSequencesTool tool = new MergeViewIndexIdSequencesTool(); - tool.setConf(config); - try(Connection conn = DriverManager.getConnection(getUrl())) { + tool.setConf(getConfiguration()); + try(Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute(CLEAN_QUERY); try (PreparedStatement preparedStatement = conn.prepareStatement(UPSERT_QUERY)) { preparedStatement.setString(1, null); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetaDataEndPointIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetaDataEndPointIT.java index 3c1446e4673..33d099f7669 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetaDataEndPointIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetaDataEndPointIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -26,8 +27,8 @@ import org.apache.hadoop.hbase.client.Table; import org.apache.hadoop.metrics2.lib.DynamicMetricsRegistry; import org.apache.phoenix.coprocessorclient.MetaDataProtocol.MutationCode; -import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.monitoring.IndexMetricsIT; import org.apache.phoenix.schema.PIndexState; import org.apache.phoenix.schema.PTable; @@ -36,10 +37,10 @@ import org.apache.phoenix.schema.metrics.MetricsMetadataSourceImpl; import org.apache.phoenix.util.EnvironmentEdgeManager; import org.apache.phoenix.util.IndexUtil; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.SchemaUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class MetaDataEndPointIT extends ParallelStatsDisabledIT { @Test @@ -49,11 +50,11 @@ public void testUpdateIndexState() throws Throwable { String indexName1 = generateUniqueName(); final String fullTableName = SchemaUtil.getTableName(schemaName, tableName); String fullIndexName1 = SchemaUtil.getTableName(schemaName, indexName1); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute("CREATE TABLE " + fullTableName + "(k INTEGER PRIMARY KEY, v1 INTEGER, v2 INTEGER) COLUMN_ENCODED_BYTES = 0, STORE_NULLS=true, GUIDE_POSTS_WIDTH=1000"); conn.createStatement().execute("CREATE INDEX " + indexName1 + " ON " + fullTableName + " (v1) INCLUDE (v2)"); conn.commit(); - Table metaTable = conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME_BYTES); + Table metaTable = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getTable(PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME_BYTES); MutationCode code = IndexUtil.updateIndexState(fullIndexName1, 0L, metaTable, PIndexState.DISABLE).getMutationCode(); assertEquals(MutationCode.TABLE_ALREADY_EXISTS, code); long ts = EnvironmentEdgeManager.currentTimeMillis(); @@ -67,7 +68,7 @@ public void testMetadataMetricsOfCreateTable() throws Throwable { String schemaName = generateUniqueName(); String tableName = generateUniqueName(); final String fullTableName = SchemaUtil.getTableName(schemaName, tableName); - try (PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl())) { + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { MetricsMetadataSourceImpl metricsSource = (MetricsMetadataSourceImpl) MetricsMetadataSourceFactory.getMetadataMetricsSource(); DynamicMetricsRegistry registry = metricsSource.getMetricsRegistry(); long expectedCreateTableCount = @@ -101,7 +102,7 @@ public void testMetadataMetricsOfDropTable() throws Throwable { String schemaName = generateUniqueName(); String tableName = generateUniqueName(); final String fullTableName = SchemaUtil.getTableName(schemaName, tableName); - try (PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl())) { + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { MetricsMetadataSourceImpl metricsSource = (MetricsMetadataSourceImpl) MetricsMetadataSourceFactory.getMetadataMetricsSource(); DynamicMetricsRegistry registry = metricsSource.getMetricsRegistry(); @@ -133,7 +134,7 @@ public void testMetadataMetricsOfAlterTableAddCol() throws Throwable { String schemaName = generateUniqueName(); String tableName = generateUniqueName(); final String fullTableName = SchemaUtil.getTableName(schemaName, tableName); - try (PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl())) { + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { MetricsMetadataSourceImpl metricsSource = (MetricsMetadataSourceImpl) MetricsMetadataSourceFactory.getMetadataMetricsSource(); DynamicMetricsRegistry registry = metricsSource.getMetricsRegistry(); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetaDataEndpointImplIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetaDataEndpointImplIT.java index 93e5557c4df..a7f8c16ed0c 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetaDataEndpointImplIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetaDataEndpointImplIT.java @@ -1,5 +1,6 @@ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; @@ -17,6 +18,7 @@ import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.schema.PColumn; import org.apache.phoenix.schema.PTable; import org.apache.phoenix.schema.TableNotFoundException; @@ -68,7 +70,7 @@ public void testGettingChildrenAndParentViews() throws Exception { String leftChild = generateUniqueName(); String rightChild = generateUniqueName(); String leftGrandChild = generateUniqueName(); - PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl()); + PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String ddlFormat = "CREATE TABLE IF NOT EXISTS " + baseTable + " (" + " PK2 VARCHAR NOT NULL, V1 VARCHAR, V2 VARCHAR " + " CONSTRAINT NAME_PK PRIMARY KEY (PK2)" + " )"; @@ -105,8 +107,7 @@ public void testUpsertIntoChildViewWithPK() throws Exception { String baseTable = generateUniqueName(); String view = generateUniqueName(); String childView = generateUniqueName(); - - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String baseTableDDL = "CREATE TABLE IF NOT EXISTS " + baseTable + " (TENANT_ID VARCHAR NOT NULL, KEY_PREFIX CHAR(3) NOT NULL, " + "V1 VARCHAR CONSTRAINT PK PRIMARY KEY(TENANT_ID, KEY_PREFIX)) " @@ -137,8 +138,7 @@ public void testUpsertIntoTenantChildViewWithPK() throws Exception { String view = generateUniqueName(); String childView = generateUniqueName(); String tenantId = "TENANT"; - - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String baseTableDDL = "CREATE TABLE IF NOT EXISTS " + baseTable + " (TENANT_ID VARCHAR NOT NULL, KEY_PREFIX CHAR(3) NOT NULL, " + "V1 VARCHAR CONSTRAINT PK PRIMARY KEY(TENANT_ID, KEY_PREFIX)) " @@ -151,7 +151,7 @@ public void testUpsertIntoTenantChildViewWithPK() throws Exception { conn.createStatement().execute(view1DDL); // Create a child view with primary key constraint owned by tenant - Properties tenantProps = new Properties(); + Properties tenantProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); try (Connection tenantConn = DriverManager.getConnection(getUrl(), tenantProps)) { String childViewDDL = "CREATE VIEW IF NOT EXISTS " + childView @@ -171,7 +171,7 @@ public void testUpsertIntoTenantChildViewWithPK() throws Exception { public void testGettingOneChild() throws Exception { String baseTable = generateUniqueName(); String leftChild = generateUniqueName(); - PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl()); + PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String ddlFormat = "CREATE TABLE IF NOT EXISTS " + baseTable + " (" + " PK2 VARCHAR NOT NULL, V1 VARCHAR, V2 VARCHAR " + " CONSTRAINT NAME_PK PRIMARY KEY (PK2)" + " )"; @@ -187,7 +187,7 @@ public void testGettingOneChild() throws Exception { public void testDroppingADerivedColumn() throws Exception { String baseTable = generateUniqueName(); String childView = generateUniqueName(); - PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl()); + PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String ddlFormat = "CREATE TABLE " + baseTable + " (A VARCHAR PRIMARY KEY, B VARCHAR, C VARCHAR)"; conn.createStatement().execute(ddlFormat); conn.createStatement().execute("CREATE VIEW " + childView + " (D VARCHAR) AS SELECT * FROM " + baseTable); @@ -202,7 +202,7 @@ public void testDroppingADerivedColumn() throws Exception { @Test public void testUpdateCacheWithAlteringColumns() throws Exception { String tableName = generateUniqueName(); - try (PhoenixConnection conn = DriverManager.getConnection(getUrl()).unwrap( + try (PhoenixConnection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap( PhoenixConnection.class)) { String ddlFormat = "CREATE TABLE IF NOT EXISTS " + tableName + " (" + " PK2 INTEGER NOT NULL, " @@ -212,18 +212,18 @@ public void testUpdateCacheWithAlteringColumns() throws Exception { conn.createStatement().execute("ALTER TABLE " + tableName + " ADD V3 integer"); PTable table = conn.getTable(tableName.toUpperCase()); assertColumnNamesEqual(table, "PK2", "V1", "V2", "V3"); - + // Set the SCN to the timestamp when V3 column is added Properties props = PropertiesUtil.deepCopy(conn.getClientInfo()); props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(table.getTimeStamp())); - - try (PhoenixConnection metaConnection = new PhoenixConnection(conn, + + try (PhoenixConnection metaConnection = new PhoenixConnection(conn, conn.getQueryServices(), props)) { // Force update the cache and check if V3 is present in the returned table result table = metaConnection.getTableNoCache(tableName.toUpperCase()); assertColumnNamesEqual(table, "PK2", "V1", "V2", "V3"); - } - } + } + } } @@ -231,7 +231,7 @@ public void testUpdateCacheWithAlteringColumns() throws Exception { public void testDroppingAColumn() throws Exception { String baseTable = generateUniqueName(); String childView = generateUniqueName(); - PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl()); + PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String ddlFormat = "CREATE TABLE " + baseTable + " (A VARCHAR PRIMARY KEY, B VARCHAR, C VARCHAR)"; conn.createStatement().execute(ddlFormat); conn.createStatement().execute("CREATE VIEW " + childView + " (D VARCHAR) AS SELECT * FROM " + baseTable); @@ -246,7 +246,7 @@ public void testDroppingAColumn() throws Exception { public void testAlteringBaseColumns() throws Exception { String baseTable = generateUniqueName(); String leftChild = generateUniqueName(); - PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl()); + PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)); String ddlFormat = "CREATE TABLE IF NOT EXISTS " + baseTable + " (" + " PK2 VARCHAR NOT NULL, V1 VARCHAR, V2 VARCHAR " + " CONSTRAINT NAME_PK PRIMARY KEY (PK2)" + " )"; @@ -273,7 +273,7 @@ public void testAlteringBaseColumns() throws Exception { public void testAddingAColumnWithADifferentDefinition() throws Exception { String baseTable = generateUniqueName(); String view = generateUniqueName(); - PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl()); + PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)); String ddlFormat = "CREATE TABLE IF NOT EXISTS " + baseTable + " (" + " PK2 VARCHAR NOT NULL, V1 VARCHAR, V2 VARCHAR " + " CONSTRAINT NAME_PK PRIMARY KEY (PK2)" + " )"; @@ -319,7 +319,7 @@ public void testDropCascade() throws Exception { String baseTable = generateUniqueName(); String child = generateUniqueName(); String grandChild = generateUniqueName(); - PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl()); + PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)); String ddlFormat = "CREATE TABLE IF NOT EXISTS " + baseTable + " (" + " PK2 VARCHAR NOT NULL, V1 VARCHAR, V2 VARCHAR " + " CONSTRAINT NAME_PK PRIMARY KEY (PK2)" + " )"; @@ -355,7 +355,7 @@ public void testDropCascade() throws Exception { @Test public void testWhereClause() throws Exception { - PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl()); + PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)); String baseTableName = generateUniqueName(); String childViewName = generateUniqueName(); String grandChildViewName = generateUniqueName(); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetadataGetTableReadLockIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetadataGetTableReadLockIT.java index 589748c4918..6a3795c257f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetadataGetTableReadLockIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MetadataGetTableReadLockIT.java @@ -23,6 +23,7 @@ import org.apache.phoenix.query.BaseTest; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.TestUtil; import org.junit.AfterClass; @@ -38,6 +39,8 @@ import java.util.Map; import java.util.concurrent.CountDownLatch; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; /** * Class which tests whether non-exclusive locking on metadata read path (getTable) works as expected. */ @@ -49,7 +52,11 @@ public static synchronized void doSetup() throws Exception { Map props = Maps.newHashMapWithExpectedSize(1); // Disable system task handling props.put(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); - setUpTestDriver(new ReadOnlyProps(props)); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props), new ReadOnlyProps(props)); + } else { + setUpTestDriver(new ReadOnlyProps(props)); + } } /** @@ -62,7 +69,7 @@ public void testBlockedReadDoesNotBlockAnotherRead() throws Exception { long SLEEP_DURATION = 5000L; String tableName = generateUniqueName(); CountDownLatch sleepSignal = new CountDownLatch(1); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { // create table conn.createStatement().execute("CREATE TABLE " + tableName + "(k INTEGER NOT NULL PRIMARY KEY, v1 INTEGER, v2 INTEGER)"); @@ -143,7 +150,7 @@ protected Region.RowLock acquireLock(Region region, byte[] lockKey, List tableTTLMap = createMultiHBaseTablesAndEquivalentInSYSCAT(schema, admin); - try (PhoenixConnection conn = getConnection(false, null).unwrap(PhoenixConnection.class); + try (PhoenixMonitoredConnection conn = getConnection(false, null).unwrap(PhoenixMonitoredConnection.class); Connection metaConn = getConnection(false, null, false, false)){ PhoenixConnection phxMetaConn = metaConn.unwrap(PhoenixConnection.class); phxMetaConn.setRunningUpgrade(true); @@ -116,7 +118,7 @@ public void testMoveHBaseLevelTTLToSYSCAT() throws Exception { if (ttlInSyscat == TTL_DEFINED_IN_TABLE_DESCRIPTOR) { assertEquals(ttl, columnFamilies[0].getTimeToLive()); assertEquals(new LiteralTTLExpression(TTL_DEFINED_IN_TABLE_DESCRIPTOR), - phxMetaConn.unwrap(PhoenixConnection.class).getTableNoCache( + phxMetaConn.unwrap(PhoenixMonitoredConnection.class).getTableNoCache( null, SchemaUtil.getTableName(Bytes.toBytes(schema), Bytes.toBytes(table))).getTTLExpression()); @@ -190,7 +192,7 @@ private Connection getConnection(boolean tenantSpecific, String tenantId, checkNotNull(tenantId); return createTenantConnection(tenantId); } - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); if (isNamespaceMappingEnabled){ props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, "true"); } @@ -204,7 +206,7 @@ private Connection getConnection(boolean tenantSpecific, String tenantId) throws } private Connection createTenantConnection(String tenantId) throws SQLException { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); return DriverManager.getConnection(getUrl(), props); } 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 837835a3ebc..bc6331e702a 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,7 +44,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsEnabledTest.class) public class MultiCfQueryExecIT extends ParallelStatsEnabledIT { private String fullTableName; @@ -345,7 +344,7 @@ public void testEssentialColumnFamilyForRowKeyFilter() throws Exception { @Test public void testCFWildcardProjection() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " (pk1 INTEGER NOT NULL PRIMARY KEY, x.v1 VARCHAR, y.v2 INTEGER)"; @@ -376,7 +375,7 @@ public void testCFWildcardProjection() throws Exception { @Test public void testMultipleCFWildcardProjection() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " (pk1 INTEGER NOT NULL PRIMARY KEY, x.v1 VARCHAR, y.v2 INTEGER, z.v3 INTEGER)"; @@ -410,7 +409,7 @@ public void testMultipleCFWildcardProjection() throws Exception { @Test public void testMixedDefaultAndExplicitCFs() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " (pk1 INTEGER NOT NULL PRIMARY KEY, v1 VARCHAR, y.v1 INTEGER)"; @@ -436,7 +435,7 @@ public void testMixedDefaultAndExplicitCFs() throws Exception { @Test public void testBug3890() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tableName = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " (HOST CHAR(2) NOT NULL," @@ -504,7 +503,7 @@ public void testBug3890() throws Exception { @Test public void testBug4658() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { String tableName = generateUniqueName(); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationBatchFailedStateMetricWithAllDeleteIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationBatchFailedStateMetricWithAllDeleteIT.java index a4b3d4a1e06..616bb14a5f0 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationBatchFailedStateMetricWithAllDeleteIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationBatchFailedStateMetricWithAllDeleteIT.java @@ -33,6 +33,7 @@ import org.apache.phoenix.end2end.index.ImmutableIndexIT; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.monitoring.MetricType; import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.TestUtil; @@ -42,7 +43,6 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; - @Category(NeedsOwnMiniClusterTest.class) @RunWith(Parameterized.class) public class MutationBatchFailedStateMetricWithAllDeleteIT extends BaseMutationBatchFailedStateMetricIT { @@ -84,7 +84,7 @@ public void testFailedDelete() throws Exception { Assert.fail("Commit should not have succeeded"); } catch (SQLException e) { Map> mutationMetrics = - conn.unwrap(PhoenixConnection.class).getMutationMetrics(); + conn.unwrap(PhoenixMonitoredConnection.class).getMutationMetrics(); int dbfs = mutationMetrics.get(deleteTableName).get(DELETE_BATCH_FAILED_SIZE).intValue(); int upfs = diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationBatchFailedStateMetricWithAllUpsertIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationBatchFailedStateMetricWithAllUpsertIT.java index a7c14d5f113..61f6fd877c0 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationBatchFailedStateMetricWithAllUpsertIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationBatchFailedStateMetricWithAllUpsertIT.java @@ -32,6 +32,7 @@ import org.apache.phoenix.end2end.index.ImmutableIndexIT; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.monitoring.MetricType; import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.TestUtil; @@ -41,7 +42,6 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; - @Category(NeedsOwnMiniClusterTest.class) @RunWith(Parameterized.class) public class MutationBatchFailedStateMetricWithAllUpsertIT extends BaseMutationBatchFailedStateMetricIT { @@ -83,7 +83,7 @@ public void testFailedUpsert() throws Exception { Assert.fail("Commit should not have succeeded"); } catch (SQLException e) { Map> mutationMetrics = - conn.unwrap(PhoenixConnection.class).getMutationMetrics(); + conn.unwrap(PhoenixMonitoredConnection.class).getMutationMetrics(); int dbfs = mutationMetrics.get(deleteTableName).get(DELETE_BATCH_FAILED_SIZE).intValue(); int upfs = diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationBatchFailedStateMetricWithDeleteAndUpsertIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationBatchFailedStateMetricWithDeleteAndUpsertIT.java index fc135890a6f..c065c9c26ca 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationBatchFailedStateMetricWithDeleteAndUpsertIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationBatchFailedStateMetricWithDeleteAndUpsertIT.java @@ -34,6 +34,7 @@ import org.apache.phoenix.end2end.index.ImmutableIndexIT; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.monitoring.MetricType; import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.TestUtil; @@ -43,7 +44,6 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; - @Category(NeedsOwnMiniClusterTest.class) @RunWith(Parameterized.class) public class MutationBatchFailedStateMetricWithDeleteAndUpsertIT extends BaseMutationBatchFailedStateMetricIT { @@ -90,7 +90,7 @@ public void testFailedUpsertAndDelete() throws Exception { Assert.fail("Commit should not have succeeded"); } catch (SQLException e) { Map> mutationMetrics = - conn.unwrap(PhoenixConnection.class).getMutationMetrics(); + conn.unwrap(PhoenixMonitoredConnection.class).getMutationMetrics(); int dbfs = mutationMetrics.get(deleteTableName).get(DELETE_BATCH_FAILED_SIZE).intValue(); int upfs = diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationStateIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationStateIT.java index 6ca3c0de7a3..f55b77488a0 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationStateIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MutationStateIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +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.assertNotNull; @@ -48,10 +49,12 @@ import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.execute.MutationState; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.PIndexState; import org.apache.phoenix.schema.PTableType; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.Repeat; import org.apache.phoenix.util.RunUntilFailure; import org.apache.phoenix.util.SchemaUtil; @@ -62,7 +65,6 @@ import org.junit.experimental.categories.Category; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; - @Category(ParallelStatsDisabledTest.class) @RunWith(RunUntilFailure.class) public class MutationStateIT extends ParallelStatsDisabledIT { @@ -74,7 +76,7 @@ public class MutationStateIT extends ParallelStatsDisabledIT { private static final Random RAND = new Random(5); - private void upsertRows(PhoenixConnection conn, String fullTableName) throws SQLException { + private void upsertRows(PhoenixMonitoredConnection conn, String fullTableName) throws SQLException { PreparedStatement stmt = conn.prepareStatement("upsert into " + fullTableName + " (organization_id, entity_id, score) values (?,?,?)"); @@ -100,7 +102,7 @@ private static void mutateRandomly(final String upsertStmt, final String fullTab @Override public void run() { try { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); for (int i = 0; i < nRows; i++) { PreparedStatement statement = conn.prepareStatement(upsertStmt); int index = 0; @@ -273,7 +275,7 @@ public void testOnlyIndexTableWriteFromClientSide() int nIndexValues = 4000; int batchSize = 200; final CountDownLatch doneSignal = new CountDownLatch(nThreads); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { try { conn.createStatement().execute(CREATE_DATA_TABLE); conn.createStatement().execute(CREATE_INDEX_1); @@ -316,7 +318,7 @@ public void testDeleteMaxMutationSize() throws SQLException { String tableName = generateUniqueName(); int NUMBER_OF_ROWS = 20; String ddl = "CREATE TABLE " + tableName + " (V BIGINT PRIMARY KEY, K BIGINT)"; - PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl()); + PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); for(int i = 0; i < NUMBER_OF_ROWS; i++) { @@ -325,11 +327,11 @@ public void testDeleteMaxMutationSize() throws SQLException { conn.commit(); } - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.MAX_MUTATION_SIZE_ATTRIB, String.valueOf(NUMBER_OF_ROWS / 2)); - PhoenixConnection connection = - (PhoenixConnection) DriverManager.getConnection(getUrl(), props); + PhoenixMonitoredConnection connection = + (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), props); connection.setAutoCommit(false); try { @@ -344,7 +346,7 @@ public void testDeleteMaxMutationSize() throws SQLException { props.setProperty(QueryServices.MAX_MUTATION_SIZE_BYTES_ATTRIB, "10"); props.setProperty(QueryServices.MAX_MUTATION_SIZE_ATTRIB, "10000"); - connection = (PhoenixConnection) DriverManager.getConnection(getUrl(), props); + connection = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), props); connection.setAutoCommit(false); try { @@ -357,11 +359,11 @@ public void testDeleteMaxMutationSize() throws SQLException { @Test public void testUpsertMaxMutationSize() throws Exception { - Properties connectionProperties = new Properties(); + Properties connectionProperties = PropertiesUtil.deepCopy(TEST_PROPERTIES); connectionProperties.setProperty(QueryServices.MAX_MUTATION_SIZE_ATTRIB, "3"); connectionProperties.setProperty(QueryServices.MAX_MUTATION_SIZE_BYTES_ATTRIB, "1000000"); - PhoenixConnection connection = - (PhoenixConnection) DriverManager.getConnection(getUrl(), connectionProperties); + PhoenixMonitoredConnection connection = + (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), connectionProperties); String fullTableName = generateUniqueName(); try (Statement stmt = connection.createStatement()) { stmt.execute( @@ -383,7 +385,7 @@ public void testUpsertMaxMutationSize() throws Exception { connectionProperties.setProperty(QueryServices.MAX_MUTATION_SIZE_ATTRIB, "1000"); connectionProperties.setProperty(QueryServices.MAX_MUTATION_SIZE_BYTES_ATTRIB, "4"); connection = - (PhoenixConnection) DriverManager.getConnection(getUrl(), connectionProperties); + (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), connectionProperties); try { upsertRows(connection, fullTableName); fail(); @@ -399,7 +401,7 @@ public void testUpsertMaxMutationSize() throws Exception { @Test public void testMutationEstimatedSize() throws Exception { - PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl()); + PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.setAutoCommit(false); String fullTableName = generateUniqueName(); try (Statement stmt = conn.createStatement()) { @@ -408,7 +410,7 @@ public void testMutationEstimatedSize() throws Exception { } // upserting rows should increase the mutation state size - MutationState state = conn.unwrap(PhoenixConnection.class).getMutationState(); + MutationState state = conn.unwrap(PhoenixMonitoredConnection.class).getMutationState(); long prevEstimatedSize = state.getEstimatedSize(); upsertRows(conn, fullTableName); assertTrue("Mutation state size should have increased", @@ -473,9 +475,9 @@ public void testMutationEstimatedSize() throws Exception { public void testSplitMutationsIntoSameGroupForSingleRow() throws Exception { String tableName = "TBL_" + generateUniqueName(); String indexName = "IDX_" + generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.put("phoenix.mutate.batchSize", "2"); - try (PhoenixConnection conn = DriverManager.getConnection(getUrl(), props).unwrap(PhoenixConnection.class)) { + try (PhoenixMonitoredConnection conn = DriverManager.getConnection(getUrl(), props).unwrap(PhoenixMonitoredConnection.class)) { conn.setAutoCommit(false); conn.createStatement().executeUpdate( "CREATE TABLE " + tableName + " (" @@ -515,7 +517,7 @@ public void testSplitMutationsIntoSameGroupForSingleRow() throws Exception { public void testDDLwithPendingMutations() throws Exception { String tableName = generateUniqueName(); ensureTableCreated(getUrl(), tableName, TestUtil.PTSDB_NAME, null, null, null); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.PENDING_MUTATIONS_DDL_THROW_ATTRIB, Boolean.toString(true)); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { // setting auto commit to false @@ -539,17 +541,17 @@ public void testDDLwithPendingMutations() throws Exception { @Test public void testNoPendingMutationsOnDDL() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.PENDING_MUTATIONS_DDL_THROW_ATTRIB, Boolean.toString(true)); String tableName = generateUniqueName(); - try (PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl(), + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), props)) { String ddl = "create table " + tableName + " ( id1 UNSIGNED_INT not null primary key," + "appId1 VARCHAR)"; conn.createStatement().execute(ddl); // ensure table got created - Admin admin = driver.getConnectionQueryServices(getUrl(), props).getAdmin(); + Admin admin = driver.getConnectionQueryServices(getActiveUrl(), props).getAdmin(); assertNotNull(admin.getDescriptor(TableName.valueOf(tableName))); assertNotNull(conn.getTableNoCache(tableName)); } @@ -566,10 +568,10 @@ public void testUpsertMaxColumnAllowanceForOneCellPerColumn() throws Exception { } public void testUpsertColumnExceedsMaxAllowanceSize(String storageScheme) throws Exception { - Properties connectionProperties = new Properties(); + Properties connectionProperties = PropertiesUtil.deepCopy(TEST_PROPERTIES); connectionProperties.setProperty(QueryServices.HBASE_CLIENT_KEYVALUE_MAXSIZE, "20"); - try (PhoenixConnection connection = - (PhoenixConnection) DriverManager.getConnection(getUrl(), connectionProperties)) { + try (PhoenixMonitoredConnection connection = + (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), connectionProperties)) { String fullTableName = generateUniqueName(); String pk1Name = generateUniqueName(); String pk2Name = generateUniqueName(); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NamespaceSchemaMappingIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NamespaceSchemaMappingIT.java index e2c6a0fa470..45b3eedfb44 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NamespaceSchemaMappingIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NamespaceSchemaMappingIT.java @@ -34,6 +34,7 @@ import org.apache.hadoop.hbase.client.TableDescriptorBuilder; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.QueryConstants; import org.apache.phoenix.schema.types.PBoolean; import org.apache.phoenix.schema.types.PVarchar; @@ -62,7 +63,7 @@ public void testBackWardCompatibility() throws Exception { String phoenixFullTableName = schemaName + "." + tableName; String hbaseFullTableName = schemaName + ":" + tableName; - Admin admin = driver.getConnectionQueryServices(getUrl(), TestUtil.TEST_PROPERTIES).getAdmin(); + Admin admin = driver.getConnectionQueryServices(getActiveUrl(), TestUtil.TEST_PROPERTIES).getAdmin(); admin.createNamespace(NamespaceDescriptor.create(namespace).build()); admin.createTable(TableDescriptorBuilder.newBuilder(TableName.valueOf(namespace, tableName)) .setColumnFamily(ColumnFamilyDescriptorBuilder.of(QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES)).build()); @@ -95,14 +96,14 @@ public void testBackWardCompatibility() throws Exception { Table metatable = admin.getConnection().getTable( SchemaUtil.getPhysicalName(PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME_BYTES, - (conn.unwrap(PhoenixConnection.class).getQueryServices().getProps()))); + (conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getProps()))); Put p = new Put(SchemaUtil.getTableKey(null, schemaName, tableName)); p.addColumn(QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES, PhoenixDatabaseMetaData.IS_NAMESPACE_MAPPED_BYTES, PBoolean.INSTANCE.toBytes(true)); metatable.put(p); metatable.close(); - PhoenixConnection phxConn = (conn.unwrap(PhoenixConnection.class)); + PhoenixMonitoredConnection phxConn = (conn.unwrap(PhoenixMonitoredConnection.class)); phxConn.getQueryServices().clearCache(); rs = conn.createStatement().executeQuery(query); assertTrue(rs.next()); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NativeHBaseTypesIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NativeHBaseTypesIT.java index 26a0ede7240..4029a27959b 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NativeHBaseTypesIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NativeHBaseTypesIT.java @@ -47,6 +47,7 @@ import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding; import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.ConnectionQueryServices; import org.apache.phoenix.query.QueryConstants; import org.apache.phoenix.util.ByteUtil; @@ -66,7 +67,6 @@ * * @since 0.1 */ - @Category(ParallelStatsDisabledTest.class) public class NativeHBaseTypesIT extends ParallelStatsDisabledIT { @@ -75,7 +75,7 @@ private String initTableValues() throws Exception { final byte[] tableBytes = tableName.getBytes(); final byte[] familyName = Bytes.toBytes(SchemaUtil.normalizeIdentifier("1")); final byte[][] splits = new byte[][] {Bytes.toBytes(20), Bytes.toBytes(30)}; - Admin admin = driver.getConnectionQueryServices(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).getAdmin(); + Admin admin = driver.getConnectionQueryServices(getActiveUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).getAdmin(); try { admin.createTable(TableDescriptorBuilder.newBuilder(TableName.valueOf(tableBytes)) .setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(familyName) @@ -84,8 +84,7 @@ private String initTableValues() throws Exception { } finally { admin.close(); } - - ConnectionQueryServices services = driver.getConnectionQueryServices(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + ConnectionQueryServices services = driver.getConnectionQueryServices(getActiveUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Table hTable = services.getTable(tableBytes); try { // Insert rows using standard HBase mechanism with standard HBase "types" @@ -151,8 +150,7 @@ private String initTableValues() throws Exception { " \"1\".ulong_col unsigned_long" + " CONSTRAINT pk PRIMARY KEY (uint_key, ulong_key, string_key))\n" + ColumnFamilyDescriptorBuilder.DATA_BLOCK_ENCODING + "='" + DataBlockEncoding.NONE + "'"; - - try (Connection conn = DriverManager.getConnection(url)) { + try (Connection conn = DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute(ddl); } @@ -163,7 +161,7 @@ private String initTableValues() throws Exception { public void testRangeQuery1() throws Exception { String tableName = initTableValues(); String query = "SELECT uint_key, ulong_key, string_key FROM " + tableName + " WHERE uint_key > 20 and ulong_key >= 400"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { PreparedStatement statement = conn.prepareStatement(query); ResultSet rs = statement.executeQuery(); @@ -181,7 +179,7 @@ public void testRangeQuery1() throws Exception { public void testRangeQuery2() throws Exception { String tableName = initTableValues(); String query = "SELECT uint_key, ulong_key, string_key FROM " + tableName + " WHERE uint_key > 20 and uint_key < 40"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { PreparedStatement statement = conn.prepareStatement(query); ResultSet rs = statement.executeQuery(); @@ -218,7 +216,7 @@ public void testRangeQuery3() throws Exception { public void testNegativeAgainstUnsignedNone() throws Exception { String tableName = initTableValues(); String query = "SELECT uint_key, ulong_key, string_key FROM " + tableName + " WHERE ulong_key < -1"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { PreparedStatement statement = conn.prepareStatement(query); ResultSet rs = statement.executeQuery(); @@ -232,7 +230,7 @@ public void testNegativeAgainstUnsignedNone() throws Exception { public void testNegativeAgainstUnsignedAll() throws Exception { String tableName = initTableValues(); String query = "SELECT string_key FROM " + tableName + " WHERE ulong_key > -100"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { PreparedStatement statement = conn.prepareStatement(query); ResultSet rs = statement.executeQuery(); @@ -253,7 +251,7 @@ public void testNegativeAgainstUnsignedAll() throws Exception { @Test public void testNegativeAddNegativeValue() throws Exception { String tableName = initTableValues(); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { PreparedStatement stmt = conn.prepareStatement("UPSERT INTO " + tableName + "(uint_key,ulong_key,string_key, uint_col) VALUES(?,?,?,?)"); stmt.setInt(1, -1); @@ -271,7 +269,7 @@ public void testNegativeAddNegativeValue() throws Exception { public void testNegativeCompareNegativeValue() throws Exception { String tableName = initTableValues(); String query = "SELECT string_key FROM " + tableName + " WHERE uint_key > 100000"; - PhoenixConnection conn = DriverManager.getConnection(getUrl()).unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixMonitoredConnection.class); Table hTable = conn.getQueryServices().getTable(tableName.getBytes()); List mutations = new ArrayList(); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NoLookbackMutableIndexExtendedIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NoLookbackMutableIndexExtendedIT.java index 08c331d416e..7727b711646 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NoLookbackMutableIndexExtendedIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NoLookbackMutableIndexExtendedIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; @@ -35,6 +36,7 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.BaseTest; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.PIndexState; @@ -50,7 +52,6 @@ import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; - @RunWith(Parameterized.class) @Category(NeedsOwnMiniClusterTest.class) public class NoLookbackMutableIndexExtendedIT extends BaseTest { @@ -61,6 +62,11 @@ public class NoLookbackMutableIndexExtendedIT extends BaseTest { public static synchronized void doSetup() throws Exception { Map props = Maps.newHashMapWithExpectedSize(1); setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } public NoLookbackMutableIndexExtendedIT(Boolean localIndex, String txProvider, Boolean columnEncoded) { @@ -133,14 +139,14 @@ public void testCompactDisabledIndex() throws Exception { conn.commit(); // disable the index, simulating an index write failure - PhoenixConnection pConn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pConn = conn.unwrap(PhoenixMonitoredConnection.class); IndexUtil.updateIndexState(pConn, indexTableFullName, PIndexState.DISABLE, EnvironmentEdgeManager.currentTimeMillis()); // major compaction should not remove the deleted row hRegion.flush(true); hRegion.compact(true); - Table dataTable = conn.unwrap(PhoenixConnection.class).getQueryServices() + Table dataTable = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices() .getTable(Bytes.toBytes(dataTableFullName)); assertEquals(1, TestUtil.getRawRowCount(dataTable)); @@ -151,7 +157,7 @@ public void testCompactDisabledIndex() throws Exception { // now major compaction should remove the deleted row hRegion.compact(true); - dataTable = conn.unwrap(PhoenixConnection.class).getQueryServices() + dataTable = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices() .getTable(Bytes.toBytes(dataTableFullName)); assertEquals(0, TestUtil.getRawRowCount(dataTable)); } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NotQueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NotQueryIT.java index 1e790ae419d..64833700870 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NotQueryIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NotQueryIT.java @@ -45,7 +45,6 @@ import org.apache.phoenix.thirdparty.com.google.common.primitives.Doubles; import org.apache.phoenix.thirdparty.com.google.common.primitives.Floats; - @RunWith(Parameterized.class) public abstract class NotQueryIT extends BaseQueryIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NotQueryWithGlobalImmutableIndexesIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NotQueryWithGlobalImmutableIndexesIT.java index f98eaad43ca..fd40f4b5f20 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NotQueryWithGlobalImmutableIndexesIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NotQueryWithGlobalImmutableIndexesIT.java @@ -24,7 +24,6 @@ import org.junit.runners.Parameterized.Parameters; import org.apache.phoenix.thirdparty.com.google.common.collect.Lists; - @Category(ParallelStatsDisabledTest.class) public class NotQueryWithGlobalImmutableIndexesIT extends NotQueryIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NotQueryWithLocalImmutableIndexesIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NotQueryWithLocalImmutableIndexesIT.java index cdd20272130..1efb6b4ac6a 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NotQueryWithLocalImmutableIndexesIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NotQueryWithLocalImmutableIndexesIT.java @@ -24,7 +24,6 @@ import org.junit.runners.Parameterized.Parameters; import org.apache.phoenix.thirdparty.com.google.common.collect.Lists; - @Category(ParallelStatsDisabledTest.class) public class NotQueryWithLocalImmutableIndexesIT extends NotQueryIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NthValueFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NthValueFunctionIT.java index c65b6fcd784..6c989b8732d 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NthValueFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NthValueFunctionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +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; @@ -26,16 +27,16 @@ import java.sql.ResultSet; import java.util.ArrayList; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class NthValueFunctionIT extends ParallelStatsDisabledIT { @Test public void simpleTest() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String nthValue = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + nthValue + " " @@ -64,7 +65,7 @@ public void simpleTest() throws Exception { @Test public void multipleNthValueFunctionTest() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String nthValue = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + nthValue + " " @@ -129,7 +130,7 @@ public void multipleNthValueFunctionTest() throws Exception { @Test public void offsetValueAscOrder() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String nth_test_table = generateUniqueName(); @@ -163,8 +164,7 @@ public void offsetValueAscOrder() throws Exception { @Test public void offsetValueDescOrder() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); - + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String nth_test_table = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + nth_test_table + " " + "(id INTEGER NOT NULL PRIMARY KEY, page_id UNSIGNED_LONG," @@ -196,7 +196,7 @@ public void offsetValueDescOrder() throws Exception { @Test public void offsetValueSubAggregation() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String nth_test_table = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + nth_test_table + " " @@ -230,7 +230,7 @@ public void offsetValueSubAggregation() throws Exception { @Test public void offsetValueLastMismatchByColumn() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String nth_test_table = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + nth_test_table + " " @@ -263,8 +263,7 @@ public void offsetValueLastMismatchByColumn() throws Exception { @Test public void testSortOrderInDataColWithOffset() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); - + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String nth_test_table = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + nth_test_table + " " + "(id INTEGER NOT NULL, page_id UNSIGNED_LONG," @@ -294,7 +293,7 @@ public void testSortOrderInDataColWithOffset() throws Exception { @Test public void nonUniqueValuesInOrderByAsc() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String nthValue = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + nthValue + " " @@ -325,7 +324,7 @@ public void nonUniqueValuesInOrderByAsc() throws Exception { @Test public void nonUniqueValuesInOrderByAscSkipDuplicit() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String nthValue = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + nthValue + " " @@ -356,7 +355,7 @@ public void nonUniqueValuesInOrderByAscSkipDuplicit() throws Exception { @Test public void nonUniqueValuesInOrderByDesc() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String nthValue = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + nthValue + " " @@ -387,7 +386,7 @@ public void nonUniqueValuesInOrderByDesc() throws Exception { @Test public void nonUniqueValuesInOrderNextValueDesc() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String nthValue = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + nthValue + " " @@ -420,7 +419,7 @@ public void nonUniqueValuesInOrderNextValueDesc() throws Exception { @Test public void nonUniqueValuesInOrderNextValueAsc() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String nthValue = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + nthValue + " " @@ -453,7 +452,7 @@ public void nonUniqueValuesInOrderNextValueAsc() throws Exception { @Test public void ignoreNullValues() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String nth_test_table = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + nth_test_table + " " @@ -492,7 +491,7 @@ private void assertInIntArray(int[] should, int actualValue) { @Test public void testUnionAll() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String nthValue = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + nthValue + " " diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NullIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NullIT.java index 36a008b71bc..f91a1956e92 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NullIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NullIT.java @@ -49,7 +49,6 @@ import org.junit.runners.Parameterized.Parameters; import org.apache.phoenix.thirdparty.com.google.common.collect.Lists; - @Category(ParallelStatsDisabledTest.class) public class NullIT extends BaseQueryIT { @@ -155,7 +154,7 @@ public void testIsNotNull() throws Exception { // PHOENIX-6583 @Test public void testBinaryNullAssignment() throws SQLException { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); ResultSet rs; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NumericArithmeticIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NumericArithmeticIT.java index 280ef4b7d24..c66926a7f90 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NumericArithmeticIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NumericArithmeticIT.java @@ -44,7 +44,6 @@ import org.junit.experimental.categories.Category; import org.apache.phoenix.thirdparty.com.google.common.primitives.Doubles; import org.apache.phoenix.thirdparty.com.google.common.primitives.Floats; - @Category(ParallelStatsDisabledTest.class) public class NumericArithmeticIT extends ParallelStatsDisabledIT { private String tableName; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OctetLengthFunctionEnd2EndIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OctetLengthFunctionEnd2EndIT.java index c77c5b217c6..6e2cd14d04d 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OctetLengthFunctionEnd2EndIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OctetLengthFunctionEnd2EndIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.apache.phoenix.util.TestUtil.closeStmtAndConn; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -27,6 +28,7 @@ import java.sql.ResultSet; import org.apache.phoenix.expression.function.OctetLengthFunction; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -45,7 +47,7 @@ public void initTable() throws Exception { Connection conn = null; PreparedStatement stmt = null; try { - conn = DriverManager.getConnection(getUrl()); + conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String ddl; ddl = "CREATE TABLE " + TABLE_NAME + " (k VARCHAR NOT NULL PRIMARY KEY, b BINARY(4), vb1 VARBINARY, vb2 VARBINARY)"; @@ -58,7 +60,7 @@ public void initTable() throws Exception { @Test public void test() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); PreparedStatement stmt = conn.prepareStatement( "UPSERT INTO " + TABLE_NAME + "(k,b,vb1) VALUES (?, ?, ?)"); stmt.setString(1, KEY); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OnDuplicateKey2IT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OnDuplicateKey2IT.java index 8a795640034..9546624d1a8 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OnDuplicateKey2IT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OnDuplicateKey2IT.java @@ -51,6 +51,7 @@ import org.apache.phoenix.compile.ExplainPlan; import org.apache.phoenix.compile.ExplainPlanAttributes; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixPreparedStatement; import org.apache.phoenix.jdbc.PhoenixStatement; import org.apache.phoenix.query.QueryConstants; @@ -70,7 +71,6 @@ import org.junit.runners.Parameterized.Parameters; import org.apache.phoenix.thirdparty.com.google.common.collect.Lists; - @Category(NeedsOwnMiniClusterTest.class) @RunWith(Parameterized.class) public class OnDuplicateKey2IT extends ParallelStatsDisabledIT { @@ -1379,7 +1379,7 @@ private void testBatchedUpsertOnDupKey(boolean autocommit) throws Exception { } private long getEmptyKVLatestCellTimestamp(String tableName) throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); PTable pTable = PhoenixRuntime.getTable(conn, tableName); byte[] emptyCQ = EncodedColumnsUtil.getEmptyKeyValueInfo(pTable).getFirst(); return getColumnLatestCellTimestamp(tableName, emptyCQ); @@ -1388,7 +1388,7 @@ private long getEmptyKVLatestCellTimestamp(String tableName) throws Exception { private long getColumnLatestCellTimestamp(String tableName, byte[] cq) throws Exception { Scan scan = new Scan(); try (org.apache.hadoop.hbase.client.Connection hconn = - ConnectionFactory.createConnection(config)) { + ConnectionFactory.createConnection(getConfiguration())) { Table table = hconn.getTable(TableName.valueOf(tableName)); ResultScanner resultScanner = table.getScanner(scan); Result result = resultScanner.next(); @@ -1399,7 +1399,7 @@ private long getColumnLatestCellTimestamp(String tableName, byte[] cq) throws Ex private List getAllColumnsLatestCellTimestamp(Connection conn, String tableName) throws Exception { List timestampList = new ArrayList<>(); - PTable pTable = conn.unwrap(PhoenixConnection.class).getTable(new PTableKey(null, tableName)); + PTable pTable = conn.unwrap(PhoenixMonitoredConnection.class).getTable(new PTableKey(null, tableName)); List columns = pTable.getColumns(); // timestamp of the empty cell diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OnDuplicateKeyIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OnDuplicateKeyIT.java index 4bc4dc33743..04cb2e7af2c 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OnDuplicateKeyIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OnDuplicateKeyIT.java @@ -57,7 +57,6 @@ import org.junit.runners.Parameterized.Parameters; import org.apache.phoenix.thirdparty.com.google.common.collect.Lists; - @Category(ParallelStatsDisabledTest.class) @RunWith(Parameterized.class) public class OnDuplicateKeyIT extends ParallelStatsDisabledIT { @@ -917,7 +916,7 @@ private void assertHBaseRowTimestamp(String tableName, long expectedTimestamp) t } private long getEmptyKVLatestCellTimestamp(String tableName) throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); PTable pTable = PhoenixRuntime.getTable(conn, tableName); byte[] emptyCQ = EncodedColumnsUtil.getEmptyKeyValueInfo(pTable).getFirst(); return getColumnLatestCellTimestamp(tableName, emptyCQ); @@ -926,7 +925,7 @@ private long getEmptyKVLatestCellTimestamp(String tableName) throws Exception { private long getColumnLatestCellTimestamp(String tableName, byte[] cq) throws Exception { Scan scan = new Scan(); try (org.apache.hadoop.hbase.client.Connection hconn = - ConnectionFactory.createConnection(config)) { + ConnectionFactory.createConnection(getConfiguration())) { Table table = hconn.getTable(TableName.valueOf(tableName)); ResultScanner resultScanner = table.getScanner(scan); Result result = resultScanner.next(); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OperationTimeoutWithReasonIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OperationTimeoutWithReasonIT.java index dc0867bbf14..7c3d3b13141 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OperationTimeoutWithReasonIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OperationTimeoutWithReasonIT.java @@ -20,6 +20,7 @@ import org.apache.phoenix.util.EnvironmentEdge; import org.apache.phoenix.util.EnvironmentEdgeManager; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -31,6 +32,7 @@ import java.sql.Statement; import static org.apache.phoenix.exception.SQLExceptionCode.OPERATION_TIMED_OUT; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -60,8 +62,8 @@ public void testOperationTimeout() throws SQLException { final String tableName = generateUniqueName(); final String ddl = "CREATE TABLE " + tableName + " (COL1 VARCHAR NOT NULL PRIMARY KEY, COL2 VARCHAR)"; - try (Connection conn = DriverManager.getConnection(getUrl()); - Statement stmt = conn.createStatement()) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Statement stmt = conn.createStatement()) { stmt.execute(ddl); final String dml = String.format("UPSERT INTO %s VALUES (?, ?)", tableName); @@ -75,7 +77,7 @@ public void testOperationTimeout() throws SQLException { conn.commit(); } - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.setQueryTimeout(5); // 5 sec ResultSet rs = stmt.executeQuery(String.format("SELECT * FROM %s", diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByIT.java index 490dd458957..74e2ecd1eb4 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByIT.java @@ -24,7 +24,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class OrderByIT extends BaseOrderByIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByWithRegionMovesIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByWithRegionMovesIT.java index f7a91f31c4c..0abc212311f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByWithRegionMovesIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByWithRegionMovesIT.java @@ -18,7 +18,6 @@ package org.apache.phoenix.end2end; import org.junit.experimental.categories.Category; - @Category(NeedsOwnMiniClusterTest.class) public class OrderByWithRegionMovesIT extends BaseOrderByWithRegionMovesIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByWithServerClientSpoolingDisabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByWithServerClientSpoolingDisabledIT.java index 91f2a694a99..dd76d2fbf8e 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByWithServerClientSpoolingDisabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByWithServerClientSpoolingDisabledIT.java @@ -27,6 +27,8 @@ import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; + /** * Same as the order by test but with spooling disabled both on the server and client. This will use * {@link SizeBoundQueue} for all its operations @@ -43,7 +45,11 @@ public static synchronized void doSetup() throws Exception { Boolean.toString(Boolean.FALSE)); props.put(QueryServices.CLIENT_ORDERBY_SPOOLING_ENABLED_ATTRIB, Boolean.toString(Boolean.FALSE)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByWithServerMemoryLimitIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByWithServerMemoryLimitIT.java index 8bf0589adbc..e3e77cc6d6c 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByWithServerMemoryLimitIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByWithServerMemoryLimitIT.java @@ -10,6 +10,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -31,7 +32,6 @@ import org.junit.experimental.categories.Category; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; - @Category(NeedsOwnMiniClusterTest.class) public class OrderByWithServerMemoryLimitIT extends BaseTest { @@ -41,7 +41,11 @@ public static synchronized void doSetup() throws Exception { props.put(QueryServices.SERVER_SPOOL_THRESHOLD_BYTES_ATTRIB, Integer.toString(1)); props.put(QueryServices.SERVER_ORDERBY_SPOOLING_ENABLED_ATTRIB, Boolean.toString(Boolean.FALSE)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @Test diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByWithSpillingIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByWithSpillingIT.java index 3c8308924cb..512bfe98682 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByWithSpillingIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrderByWithSpillingIT.java @@ -26,6 +26,8 @@ import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; + @Category(NeedsOwnMiniClusterTest.class) public class OrderByWithSpillingIT extends BaseOrderByIT { @BeforeClass @@ -34,6 +36,10 @@ public static synchronized void doSetup() throws Exception { // do lot's of spooling! props.put(QueryServices.SERVER_SPOOL_THRESHOLD_BYTES_ATTRIB, Integer.toString(1)); props.put(QueryServices.CLIENT_SPOOL_THRESHOLD_BYTES_ATTRIB, Integer.toString(1)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrphanViewToolIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrphanViewToolIT.java index 25e684f1d95..3581bf8c046 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrphanViewToolIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrphanViewToolIT.java @@ -17,12 +17,14 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.LINK_TYPE; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CHILD_LINK_NAME; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_SCHEM; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_TYPE; import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB; +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; @@ -47,6 +49,7 @@ import org.apache.phoenix.mapreduce.OrphanViewTool; import org.apache.phoenix.schema.PTable; import org.apache.phoenix.schema.PTableType; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; import org.junit.AfterClass; @@ -58,7 +61,6 @@ import org.junit.runners.Parameterized.Parameters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - @Category(NeedsOwnMiniClusterTest.class) @RunWith(Parameterized.class) public class OrphanViewToolIT extends BaseOwnClusterIT { @@ -136,7 +138,11 @@ public static synchronized Collection data() { @BeforeClass public static synchronized void doSetup() throws Exception { - setUpTestDriver(ReadOnlyProps.EMPTY_PROPS); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(ReadOnlyProps.EMPTY_PROPS, ReadOnlyProps.EMPTY_PROPS); + } else { + setUpTestDriver(ReadOnlyProps.EMPTY_PROPS); + } //Create these after the minicluster has started, and overwritten java.io.tmpdir tmpDir = Files.createTempDirectory(OrphanViewToolIT.class.getCanonicalName()).toString(); viewFileName = Paths.get(tmpDir, OrphanViewTool.fileName[OrphanViewTool.VIEW]).toString(); @@ -249,9 +255,9 @@ private void verifyCountQuery(Connection connection, String query, String schema public void testCreateTableAndViews() throws Exception { String baseTableName = generateUniqueName(); String baseTableFullName = SchemaUtil.getTableName(SCHEMA1, baseTableName); - try (Connection connection = DriverManager.getConnection(getUrl()); + try (Connection connection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection viewConnection = - isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL) : connection) { + isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL, PropertiesUtil.deepCopy(TEST_PROPERTIES)) : connection) { createBaseTableIndexAndViews(connection, baseTableFullName, viewConnection, SCHEMA2, SCHEMA3, SCHEMA4); // Run the orphan view tool to drop orphan views but no view should be dropped runOrphanViewTool(true, false, true, false); @@ -294,9 +300,9 @@ private void executeDeleteQuery(Connection connection, String deleteQuery, Strin public void testDeleteBaseTableRows() throws Exception { String baseTableName = generateUniqueName(); String baseTableFullName = SchemaUtil.getTableName(SCHEMA1, baseTableName); - try (Connection connection = DriverManager.getConnection(getUrl()); + try (Connection connection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection viewConnection = - isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL) : connection) { + isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL, PropertiesUtil.deepCopy(TEST_PROPERTIES)) : connection) { createBaseTableIndexAndViews(connection, baseTableFullName, viewConnection, SCHEMA2, SCHEMA2, SCHEMA2); // Delete the base table row from the system catalog executeDeleteQuery(connection, deleteTableRows, SCHEMA1); @@ -328,9 +334,9 @@ public void testDeleteBaseTableRows() throws Exception { public void testDeleteChildViewRows() throws Exception { String baseTableName = generateUniqueName(); String baseTableFullName = SchemaUtil.getTableName(SCHEMA1, baseTableName); - try (Connection connection = DriverManager.getConnection(getUrl()); + try (Connection connection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection viewConnection = - isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL) : connection) { + isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL, PropertiesUtil.deepCopy(TEST_PROPERTIES)) : connection) { createBaseTableIndexAndViews(connection, baseTableFullName, viewConnection, null, SCHEMA3, SCHEMA3); // Delete the rows of the immediate child views of the base table from the system catalog executeDeleteQuery(connection, deleteViewRows, null); @@ -357,9 +363,9 @@ public void testDeleteChildViewRows() throws Exception { public void testDeleteGrandchildViewRows() throws Exception { String baseTableName = generateUniqueName(); String baseTableFullName = SchemaUtil.getTableName(SCHEMA1, baseTableName); - try (Connection connection = DriverManager.getConnection(getUrl()); + try (Connection connection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection viewConnection = - isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL) : connection) { + isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL, PropertiesUtil.deepCopy(TEST_PROPERTIES)) : connection) { createBaseTableIndexAndViews(connection, baseTableFullName, viewConnection, SCHEMA2, SCHEMA3, null); // Delete the grand child view rows from the system catalog executeDeleteQuery(connection, deleteViewRows, SCHEMA3); @@ -387,9 +393,9 @@ public void testDeleteGrandchildViewRows() throws Exception { public void testDeleteParentChildLinkRows() throws Exception { String baseTableName = generateUniqueName(); String baseTableFullName = SchemaUtil.getTableName(SCHEMA1, baseTableName); - try (Connection connection = DriverManager.getConnection(getUrl()); + try (Connection connection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection viewConnection = - isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL) : connection) { + isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL, PropertiesUtil.deepCopy(TEST_PROPERTIES)) : connection) { createBaseTableIndexAndViews(connection, baseTableFullName, viewConnection, SCHEMA2, SCHEMA3, SCHEMA4); // Delete the CHILD_TABLE links to grand child views executeDeleteQuery(connection, deleteChildLinks, SCHEMA2); @@ -415,9 +421,9 @@ public void testDeleteParentChildLinkRows() throws Exception { public void testDeleteChildParentLinkRows() throws Exception { String baseTableName = generateUniqueName(); String baseTableFullName = SchemaUtil.getTableName(SCHEMA1, baseTableName); - try (Connection connection = DriverManager.getConnection(getUrl()); + try (Connection connection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection viewConnection = - isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL) : connection) { + isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL, PropertiesUtil.deepCopy(TEST_PROPERTIES)) : connection) { createBaseTableIndexAndViews(connection, baseTableFullName, viewConnection, SCHEMA2, SCHEMA3, SCHEMA4); // Delete the PARENT_TABLE links from grand grand child views executeDeleteQuery(connection, deleteParentLinks, SCHEMA4); @@ -441,9 +447,9 @@ public void testDeleteChildParentLinkRows() throws Exception { public void testDeletePhysicalTableLinks() throws Exception { String baseTableName = generateUniqueName(); String baseTableFullName = SchemaUtil.getTableName(SCHEMA1, baseTableName); - try (Connection connection = DriverManager.getConnection(getUrl()); + try (Connection connection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection viewConnection = - isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL) : connection) { + isMultiTenant ? DriverManager.getConnection(TENANT_SPECIFIC_URL, PropertiesUtil.deepCopy(TEST_PROPERTIES)) : connection) { createBaseTableIndexAndViews(connection, baseTableFullName, viewConnection, SCHEMA2, SCHEMA3, SCHEMA3); // Delete the physical table link rows from the system catalog executeDeleteQuery(connection, deletePhysicalLinks, SCHEMA2); 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 d17c433d197..38a2bd222d2 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 @@ -49,7 +49,6 @@ import org.junit.experimental.categories.Category; import org.apache.phoenix.thirdparty.com.google.common.base.Joiner; - @Category(ParallelStatsEnabledTest.class) public class ParallelIteratorsIT extends ParallelStatsEnabledIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsDisabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsDisabledIT.java index e4941332ed0..a9b0b010e42 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsDisabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsDisabledIT.java @@ -34,6 +34,7 @@ import java.sql.SQLException; import java.util.Map; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -58,7 +59,11 @@ public static synchronized void doSetup() throws Exception { Map props = Maps.newHashMapWithExpectedSize(1); props.put(BaseScannerRegionObserverConstants.PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY, Integer.toString(60*60)); // An hour props.put(QueryServices.USE_STATS_FOR_PARALLELIZATION, Boolean.toString(false)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @AfterClass diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsDisabledWithRegionMovesIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsDisabledWithRegionMovesIT.java index 383d5a22320..6b0d6068540 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsDisabledWithRegionMovesIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsDisabledWithRegionMovesIT.java @@ -58,6 +58,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; @@ -119,7 +120,11 @@ public static synchronized void doSetup() throws Exception { props.put(HConstants.HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY, String.valueOf(1)); props.put(QueryServices.PHOENIX_POST_DUMMY_PROCESS, TestScanningResultPostDummyResultCaller.class.getName()); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @AfterClass @@ -217,7 +222,7 @@ protected static void splitAllRegionsOfTable(String tableName, int splitAtRow) { regionStatesCount.getOpenRegions() == regionStatesCount.getTotalRegions()) { try (Table table = - utility.getConnection() + getUtility().getConnection() .getTable(TableName.valueOf(tableName))) { try (ResultScanner resultScanner = table.getScanner( new Scan())) { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsEnabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsEnabledIT.java index e33b2e2b3fd..6f0ef30edd4 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsEnabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsEnabledIT.java @@ -32,6 +32,8 @@ import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; + /** * Base class for tests whose methods run in parallel with statistics enabled. * You must create unique names using {@link #generateUniqueName()} for each @@ -42,15 +44,18 @@ public abstract class ParallelStatsEnabledIT extends BaseTest { protected static RegionCoprocessorEnvironment TaskRegionEnvironment; @BeforeClass - public static synchronized final void doSetup() throws Exception { + public static synchronized void doSetup() throws Exception { Map props = Maps.newHashMapWithExpectedSize(1); props.put(QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, Long.toString(20)); props.put(QueryServices.STATS_UPDATE_FREQ_MS_ATTRIB, Long.toString(5)); props.put(QueryServices.MAX_SERVER_METADATA_CACHE_TIME_TO_LIVE_MS_ATTRIB, Long.toString(5)); props.put(QueryServices.USE_STATS_FOR_PARALLELIZATION, Boolean.toString(true)); props.put(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); - + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } TaskRegionEnvironment = getUtility() .getRSForFirstRegionInTable( diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParameterizedIndexUpgradeToolIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParameterizedIndexUpgradeToolIT.java index 86162ac03da..85a87206f48 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParameterizedIndexUpgradeToolIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParameterizedIndexUpgradeToolIT.java @@ -18,6 +18,7 @@ package org.apache.phoenix.end2end; import org.apache.phoenix.end2end.index.IndexTestUtil; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; import org.apache.commons.lang3.StringUtils; import org.apache.hadoop.hbase.TableName; @@ -68,12 +69,12 @@ import java.util.Properties; import java.util.UUID; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.mapreduce.index.IndexUpgradeTool.ROLLBACK_OP; import static org.apache.phoenix.mapreduce.index.IndexUpgradeTool.UPGRADE_OP; import static org.apache.phoenix.query.QueryServices.DROP_METADATA_ATTRIB; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.mockito.Mockito.times; - @RunWith(Parameterized.class) @Category(NeedsOwnMiniClusterTest.class) public class ParameterizedIndexUpgradeToolIT extends BaseTest { @@ -130,10 +131,14 @@ public void setup () throws Exception { setClusterProperties(); - setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), - new ReadOnlyProps(clientProps.entrySet().iterator())); - - conn = DriverManager.getConnection(getUrl(), new Properties()); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(serverProps.entrySet().iterator()), + new ReadOnlyProps(clientProps.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), + new ReadOnlyProps(clientProps.entrySet().iterator())); + } + conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.setAutoCommit(true); String tenantId = generateUniqueName(); @@ -141,7 +146,7 @@ public void setup () throws Exception { props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); connTenant = DriverManager.getConnection(getUrl(), props); - ConnectionQueryServices queryServices = conn.unwrap(PhoenixConnection.class) + ConnectionQueryServices queryServices = conn.unwrap(PhoenixMonitoredConnection.class) .getQueryServices(); admin = queryServices.getAdmin(); if (!mutable) { @@ -576,7 +581,7 @@ public void testTableReenableAfterDoubleFailure() throws Exception { } private void validateTablesEnabled(String inputList) throws IOException, SQLException { - Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin(); + Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin(); String[] tableNames = inputList.split(","); Assert.assertNotNull(tableNames); Assert.assertTrue(tableNames.length > 0); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PartialResultServerConfigurationIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PartialResultServerConfigurationIT.java index b77231520e0..db30f65d7b2 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PartialResultServerConfigurationIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PartialResultServerConfigurationIT.java @@ -28,8 +28,10 @@ import org.apache.phoenix.jdbc.PhoenixTestDriver; import org.apache.phoenix.query.ConnectionQueryServices.Feature; import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; import org.apache.phoenix.util.PhoenixRuntime; import org.apache.phoenix.util.PropertiesUtil; +import org.apache.phoenix.util.ReadOnlyProps; import org.junit.AfterClass; import org.junit.Assume; import org.junit.BeforeClass; @@ -41,13 +43,18 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement; +import java.util.Map; import java.util.Properties; import java.util.Random; import java.util.UUID; import static org.apache.hadoop.hbase.HConstants.HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.query.BaseTest.generateUniqueName; import static org.apache.phoenix.query.BaseTest.setUpConfigForMiniCluster; +import static org.apache.phoenix.query.BaseTest.setUpTestClusterForHA; +import static org.apache.phoenix.query.BaseTest.getUtility; +import static org.apache.phoenix.query.BaseTest.CLUSTERS; import static org.apache.phoenix.query.QueryServices.*; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; @@ -65,20 +72,30 @@ public class PartialResultServerConfigurationIT { @BeforeClass public static synchronized void setUp() throws Exception { - Configuration conf = HBaseConfiguration.create(); - hbaseTestUtil = new HBaseTestingUtility(conf); - setUpConfigForMiniCluster(conf); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + Map props = Maps.newHashMapWithExpectedSize(1); + //Enforce the limit of the result, so scans will stop between cells. + props.put(HConstants.HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY, "5"); + props.put(HConstants.HBASE_SERVER_SCANNER_MAX_RESULT_SIZE_KEY, "5"); + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()), new ReadOnlyProps(props.entrySet().iterator())); + hbaseTestUtil = getUtility(); + url = CLUSTERS.getJdbcHAUrlWithoutPrincipal(); + } else { + Configuration conf = HBaseConfiguration.create(); + hbaseTestUtil = new HBaseTestingUtility(conf); + setUpConfigForMiniCluster(conf); - //Enforce the limit of the result, so scans will stop between cells. - conf.setLong(HConstants.HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY, 5); - conf.setLong(HConstants.HBASE_SERVER_SCANNER_MAX_RESULT_SIZE_KEY, 5); + //Enforce the limit of the result, so scans will stop between cells. + conf.setLong(HConstants.HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY, 5); + conf.setLong(HConstants.HBASE_SERVER_SCANNER_MAX_RESULT_SIZE_KEY, 5); - hbaseTestUtil.startMiniCluster(); - zkQuorum = "localhost:" + hbaseTestUtil.getZkCluster().getClientPort(); - url = PhoenixRuntime.JDBC_PROTOCOL_ZK + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum; + hbaseTestUtil.startMiniCluster(); + zkQuorum = "localhost:" + hbaseTestUtil.getZkCluster().getClientPort(); + url = PhoenixRuntime.JDBC_PROTOCOL_ZK + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum; - DriverManager.registerDriver(PhoenixDriver.INSTANCE); - DriverManager.registerDriver(new PhoenixTestDriver()); + DriverManager.registerDriver(PhoenixDriver.INSTANCE); + DriverManager.registerDriver(new PhoenixTestDriver()); + } } @AfterClass @@ -102,7 +119,7 @@ public void testJoinScan() throws Exception { String tableNameL = generateUniqueName(); int numRecords = 1000; - try (Connection conn = DriverManager.getConnection(url)) { + try (Connection conn = DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute( "CREATE TABLE " + tableNameR + " (PK1 INTEGER NOT NULL PRIMARY KEY, KV1 VARCHAR)"); int i = 0; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PartialScannerResultsDisabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PartialScannerResultsDisabledIT.java index a412125fb6a..ee97ba2aff9 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PartialScannerResultsDisabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PartialScannerResultsDisabledIT.java @@ -10,6 +10,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -28,13 +29,13 @@ import org.apache.commons.lang3.RandomStringUtils; import org.apache.hadoop.hbase.HConstants; import org.apache.phoenix.util.IndexScrutiny; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.SchemaUtil; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - @Category(ParallelStatsDisabledTest.class) public class PartialScannerResultsDisabledIT extends ParallelStatsDisabledIT { public static final String TEST_TABLE_DDL = @@ -97,7 +98,7 @@ public void setup() throws Exception { @Test public void testWithEnoughData() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { // Write enough data to trigger partial scanner results // TODO: it's likely that less data could be written if whatever // config parameters decide this are lowered. @@ -118,7 +119,7 @@ public void testWithEnoughData() throws Exception { @Test public void partialResultDuringSelect () throws SQLException { String tableName = generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(HConstants.HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY, "5"); int numRecords = 10; try (Connection conn = DriverManager.getConnection(url, props)) { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PercentileIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PercentileIT.java index 98e92a72b48..32fbab20dbc 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PercentileIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PercentileIT.java @@ -58,7 +58,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class PercentileIT extends ParallelStatsDisabledIT { @@ -413,8 +412,7 @@ public void testPercentileContOnDescPKColumn() throws Exception { String indexDataTableName = generateUniqueName(); String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + indexDataTableName; String query = "SELECT PERCENTILE_CONT(1) WITHIN GROUP (ORDER BY long_pk ASC) FROM " + fullTableName; - - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { conn.createStatement().execute("create table " + fullTableName + TestUtil.TEST_TABLE_SCHEMA + "IMMUTABLE_ROWS=true"); populateINDEX_DATA_TABLETable(indexDataTableName); @@ -433,7 +431,7 @@ public void testPercentileContOnDescPKColumn() throws Exception { @Test public void testPercentRankOnDescPKColumn() throws Exception { String indexDataTableName = generateUniqueName(); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + indexDataTableName; String query = "SELECT PERCENT_RANK(2) WITHIN GROUP (ORDER BY long_pk ASC) FROM " + fullTableName; @@ -454,8 +452,7 @@ public void testPercentRankOnDescPKColumn() throws Exception { @Test public void testPercentileDiscOnDescPKColumn() throws Exception { String indexDataTableName = generateUniqueName(); - - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + indexDataTableName; String query = "SELECT PERCENTILE_DISC(0.4) WITHIN GROUP (ORDER BY long_pk DESC) FROM " + fullTableName; @@ -539,8 +536,7 @@ private static String initATableValues(String tenantId1, String tenantId2, byte[ Date date) throws Exception { String tableName = generateUniqueName(); ensureTableCreated(getUrl(), tableName, ATABLE_NAME, splits, null, null); - - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { // Insert all rows at ts PreparedStatement stmt = conn.prepareStatement("upsert into " + tableName + "(" diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PermissionNSDisabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PermissionNSDisabledIT.java index 95c7995dde0..b5cc65af066 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PermissionNSDisabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PermissionNSDisabledIT.java @@ -19,7 +19,6 @@ import org.junit.BeforeClass; import org.junit.experimental.categories.Category; - @Category(NeedsOwnMiniClusterTest.class) public class PermissionNSDisabledIT extends BasePermissionsIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PermissionNSDisabledWithCustomAccessControllerIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PermissionNSDisabledWithCustomAccessControllerIT.java index fb5841f2294..4cc00b436dc 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PermissionNSDisabledWithCustomAccessControllerIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PermissionNSDisabledWithCustomAccessControllerIT.java @@ -19,7 +19,6 @@ import org.junit.BeforeClass; import org.junit.experimental.categories.Category; - @Category(NeedsOwnMiniClusterTest.class) public class PermissionNSDisabledWithCustomAccessControllerIT extends PermissionNSDisabledIT{ public PermissionNSDisabledWithCustomAccessControllerIT() throws Exception { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PermissionNSEnabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PermissionNSEnabledIT.java index 292654f79cd..845489718b6 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PermissionNSEnabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PermissionNSEnabledIT.java @@ -44,7 +44,6 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; - @Category(NeedsOwnMiniClusterTest.class) public class PermissionNSEnabledIT extends BasePermissionsIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PermissionNSEnabledWithCustomAccessControllerIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PermissionNSEnabledWithCustomAccessControllerIT.java index 5f36c09214f..7f88a874f4b 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PermissionNSEnabledWithCustomAccessControllerIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PermissionNSEnabledWithCustomAccessControllerIT.java @@ -19,7 +19,6 @@ import org.junit.BeforeClass; import org.junit.experimental.categories.Category; - @Category(NeedsOwnMiniClusterTest.class) public class PermissionNSEnabledWithCustomAccessControllerIT extends PermissionNSEnabledIT{ public PermissionNSEnabledWithCustomAccessControllerIT() throws Exception { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PermissionsCacheIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PermissionsCacheIT.java index 1110cd1d1c9..9e24f5c684a 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PermissionsCacheIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PermissionsCacheIT.java @@ -38,7 +38,6 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(NeedsOwnMiniClusterTest.class) public class PermissionsCacheIT extends BasePermissionsIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixDriverIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixDriverIT.java index 5a6f94c960a..199914fe1e6 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixDriverIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixDriverIT.java @@ -17,12 +17,15 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.LINK_TYPE; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CATALOG_SCHEMA; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CATALOG_TABLE; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_NAME; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_SCHEM; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TENANT_ID; +import static org.apache.phoenix.util.PhoenixRuntime.PHOENIX_TEST_DRIVER_URL_PARAM; +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.assertNotSame; @@ -34,14 +37,17 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.Map; import java.util.Properties; +import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.snapshot.SnapshotCreationException; import org.apache.phoenix.jdbc.ConnectionInfo; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixDriver; import org.apache.phoenix.jdbc.PhoenixStatement; import org.apache.phoenix.query.BaseTest; @@ -52,13 +58,14 @@ import org.apache.phoenix.schema.PTable; import org.apache.phoenix.schema.PTable.LinkType; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.QueryUtil; +import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.util.UpgradeUtil; import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(NeedsOwnMiniClusterTest.class) public class PhoenixDriverIT extends BaseTest { @@ -69,19 +76,28 @@ public class PhoenixDriverIT extends BaseTest { @BeforeClass public static synchronized void setUp() throws Exception { - conf = HBaseConfiguration.create(); - hbaseTestUtil = new HBaseTestingUtility(conf); - setUpConfigForMiniCluster(conf); - conf.set(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS); - hbaseTestUtil.startMiniCluster(); - // establish url and quorum. Need to use PhoenixDriver and not PhoenixTestDriver - zkQuorum = "localhost:" + hbaseTestUtil.getZkCluster().getClientPort(); - url = PhoenixRuntime.JDBC_PROTOCOL_ZK + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum; - DriverManager.registerDriver(PhoenixDriver.INSTANCE); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + Map props = Maps.newHashMapWithExpectedSize(1); + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()), new ReadOnlyProps(props.entrySet().iterator())); + url = CLUSTERS.getJdbcHAUrlWithoutPrincipal()+";"+PHOENIX_TEST_DRIVER_URL_PARAM; + conf = getConfiguration(); + conf.set(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS); + + } else { + conf = HBaseConfiguration.create(); + hbaseTestUtil = new HBaseTestingUtility(conf); + setUpConfigForMiniCluster(conf); + conf.set(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS); + hbaseTestUtil.startMiniCluster(); + // establish url and quorum. Need to use PhoenixDriver and not PhoenixTestDriver + zkQuorum = "localhost:" + hbaseTestUtil.getZkCluster().getClientPort(); + url = PhoenixRuntime.JDBC_PROTOCOL_ZK + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum; + DriverManager.registerDriver(PhoenixDriver.INSTANCE); + } } public Connection createConnection(String tenantId, boolean isDifferentClient) throws SQLException { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.RETURN_SEQUENCE_VALUES_ATTRIB, "false"); // force the use of ConnectionQueryServicesImpl instead of ConnectionQueryServicesTestImpl props.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, @@ -145,7 +161,7 @@ public void helpTestViewParentIndexLookupMutipleClients(boolean isMultiTenant) t final String viewName = generateUniqueName(); try (Connection globalConn = createConnection(null, false); Connection conn1 = createConnection("tenant1", false); - PhoenixConnection conn2 = (PhoenixConnection) createConnection("tenant1", false)) { + PhoenixMonitoredConnection conn2 = (PhoenixMonitoredConnection) createConnection("tenant1", false)) { // create base table String baseTableDdl = "CREATE TABLE " + baseTableName + " (" + ( isMultiTenant ? "TENANT_ID VARCHAR(1) NOT NULL," : "") + @@ -206,8 +222,8 @@ public void testMapMultiTenantTableToNamespaceDuringUpgrade() throws SQLExceptio } try (Connection conn = createConnection(null, true)) { - String url = conn.unwrap(PhoenixConnection.class).getURL(); - Properties props = new Properties(); + String url = conn.unwrap(PhoenixMonitoredConnection.class).getURL(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.toString(true)); props.setProperty(QueryServices.IS_SYSTEM_TABLE_MAPPED_TO_NAMESPACE, Boolean.toString(false)); @@ -245,11 +261,11 @@ private String getPhysicalTable(Connection conn, String tenantId, String schemeN @Test public void testDifferentQueryServiceForServerConnection() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(QueryUtil.getConnectionUrl(props, conf), props); Connection serverConn = QueryUtil.getConnectionOnServer(props, conf); - ConnectionQueryServices cqs = conn.unwrap(PhoenixConnection.class).getQueryServices(); - ConnectionQueryServices serverCqs = serverConn.unwrap(PhoenixConnection.class).getQueryServices(); + ConnectionQueryServices cqs = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); + ConnectionQueryServices serverCqs = serverConn.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); assertNotSame(cqs, serverCqs); } } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixRegionServerEndpointIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixRegionServerEndpointIT.java index 670aba7f15d..8f1e8141d30 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixRegionServerEndpointIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixRegionServerEndpointIT.java @@ -43,28 +43,32 @@ import java.util.Map; import java.util.Properties; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; - @Category({NeedsOwnMiniClusterTest.class }) public class PhoenixRegionServerEndpointIT extends BaseTest { @BeforeClass public static synchronized void doSetup() throws Exception { Map props = Maps.newHashMapWithExpectedSize(1); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } // Tests that PhoenixRegionServerEndpoint validates the last ddl timestamp for base table. @Test public void testValidateLastDDLTimestampNoException() throws SQLException { - HRegionServer regionServer = utility.getMiniHBaseCluster().getRegionServer(0); + HRegionServer regionServer = getUtility().getMiniHBaseCluster().getRegionServer(0); PhoenixRegionServerEndpoint coprocessor = getPhoenixRegionServerEndpoint(regionServer); assertNotNull(coprocessor); ServerRpcController controller = new ServerRpcController(); String tableNameStr = generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { conn.setAutoCommit(false); String ddl = getCreateTableStmt(tableNameStr); @@ -88,12 +92,12 @@ public void testValidateLastDDLTimestampNoException() throws SQLException { // provided last ddl timestamp is less than server maintained last ddl timestamp. @Test public void testValidateLastDDLTimestampWithException() throws SQLException { - HRegionServer regionServer = utility.getMiniHBaseCluster().getRegionServer(0); + HRegionServer regionServer = getUtility().getMiniHBaseCluster().getRegionServer(0); PhoenixRegionServerEndpoint coprocessor = getPhoenixRegionServerEndpoint(regionServer); assertNotNull(coprocessor); ServerRpcController controller = new ServerRpcController(); String tableNameStr = generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { conn.setAutoCommit(false); String ddl = getCreateTableStmt(tableNameStr); @@ -120,12 +124,12 @@ public void testValidateLastDDLTimestampWithException() throws SQLException { // views @Test public void testValidateLastDDLTimestampWithTenantID() throws SQLException { - HRegionServer regionServer = utility.getMiniHBaseCluster().getRegionServer(0); + HRegionServer regionServer = getUtility().getMiniHBaseCluster().getRegionServer(0); PhoenixRegionServerEndpoint coprocessor = getPhoenixRegionServerEndpoint(regionServer); assertNotNull(coprocessor); ServerRpcController controller = new ServerRpcController(); String tableNameStr = generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { conn.setAutoCommit(false); String ddl = getCreateTableStmt(tableNameStr); @@ -159,7 +163,7 @@ public void testValidateLastDDLTimestampWithTenantID() throws SQLException { @Test public void testInvalidateHAGroupStoreClient() { - HRegionServer regionServer = utility.getMiniHBaseCluster().getRegionServer(0); + HRegionServer regionServer = getUtility().getMiniHBaseCluster().getRegionServer(0); PhoenixRegionServerEndpoint coprocessor = getPhoenixRegionServerEndpoint(regionServer); assertNotNull(coprocessor); ServerRpcController controller = new ServerRpcController(); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixRowTimestampFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixRowTimestampFunctionIT.java index e1a39a020f9..9775bcb6047 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixRowTimestampFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixRowTimestampFunctionIT.java @@ -31,6 +31,7 @@ import org.apache.phoenix.schema.PTable.QualifierEncodingScheme; import org.apache.phoenix.util.EncodedColumnsUtil; import org.apache.phoenix.util.EnvironmentEdgeManager; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -46,11 +47,11 @@ import java.util.Collection; import java.util.List; +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; - @Category(ParallelStatsDisabledTest.class) @RunWith(Parameterized.class) public class PhoenixRowTimestampFunctionIT extends ParallelStatsDisabledIT { @@ -95,7 +96,7 @@ private void verifyHbaseAllRowsTimestamp(String tableName, ResultSet rs, int exp Scan scan = new Scan(); byte[] emptyKVQualifier = EncodedColumnsUtil.getEmptyKeyValueInfo(this.encoded).getFirst(); try (org.apache.hadoop.hbase.client.Connection hconn = - ConnectionFactory.createConnection(config)) { + ConnectionFactory.createConnection(getConfiguration())) { Table table = hconn.getTable(TableName.valueOf(tableName)); ResultScanner resultScanner = table.getScanner(scan); int rowCount = 0; @@ -116,7 +117,7 @@ private void verifyHbaseRowTimestamp(String tableName, String rowKey, Date expec byte[] emptyKVQualifier = EncodedColumnsUtil.getEmptyKeyValueInfo(this.encoded).getFirst(); try (org.apache.hadoop.hbase.client.Connection hconn = - ConnectionFactory.createConnection(config)) { + ConnectionFactory.createConnection(getConfiguration())) { Table table = hconn.getTable(TableName.valueOf(tableName)); Get get = new Get(Bytes.toBytesBinary(rowKey)); Result result = table.get(get); @@ -129,7 +130,7 @@ private void verifyHbaseRowTimestamp(String tableName, String rowKey, Date expec private String createTestData(long rowTimestamp, int numRows) throws Exception { String tableName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { // Create a test table. try (Statement stmt = conn.createStatement()) { String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + @@ -161,7 +162,7 @@ private String createTestData(long rowTimestamp, int numRows) throws Exception { public void testRowTimestampDefault() throws Exception { if (encoded || optimized) return; String tableName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " (PK INTEGER NOT NULL PRIMARY KEY, KV1 VARCHAR, KV2 VARCHAR)" + this.tableDDLOptions; @@ -217,7 +218,7 @@ public void testRowTimestampDefault() throws Exception { @Test public void testRowTimestampColumn() throws Exception { String tableName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " (PK1 INTEGER NOT NULL, PK2 DATE NOT NULL, KV1 VARCHAR, KV2 VARCHAR" + " CONSTRAINT PK PRIMARY KEY(PK1, PK2 ROW_TIMESTAMP))" + this.tableDDLOptions; @@ -258,7 +259,7 @@ public void testRowTimestampFunctionAndEqualPredicate() throws Exception { long rowTimestamp = EnvironmentEdgeManager.currentTimeMillis() + TS_OFFSET; String tableName = createTestData(rowTimestamp, NUM_ROWS); // With phoenix_row_timestamp function only in projection - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String sql = "SELECT PHOENIX_ROW_TIMESTAMP() FROM " + tableName + " WHERE PHOENIX_ROW_TIMESTAMP() = PK2 "; try (Statement stmt = conn.createStatement()) { @@ -269,7 +270,7 @@ public void testRowTimestampFunctionAndEqualPredicate() throws Exception { } // With phoenix_row_timestamp function and additional columns in projection - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String sql = "SELECT PHOENIX_ROW_TIMESTAMP(), KV1 FROM " + tableName + " WHERE PHOENIX_ROW_TIMESTAMP() = PK2 "; try (Statement stmt = conn.createStatement()) { @@ -287,7 +288,7 @@ public void testRowTimestampFunctionAndEqualPredicate() throws Exception { public void testRowTimestampFunctionOnlyWithLessThanPredicate() throws Exception { long rowTimestamp = EnvironmentEdgeManager.currentTimeMillis() + TS_OFFSET; String tableName = createTestData(rowTimestamp, NUM_ROWS); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String sql = "SELECT PHOENIX_ROW_TIMESTAMP() FROM " + tableName + " WHERE PHOENIX_ROW_TIMESTAMP() < PK2 "; try (Statement stmt = conn.createStatement()) { @@ -310,7 +311,7 @@ public void testRowTimestampFunctionOnlyWithLessThanPredicate() throws Exception public void testRowTimestampFunctionAndAdditionalColsWithLessThanPredicate() throws Exception { long rowTimestamp = EnvironmentEdgeManager.currentTimeMillis() + TS_OFFSET; String tableName = createTestData(rowTimestamp, NUM_ROWS); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String sql = "SELECT PHOENIX_ROW_TIMESTAMP(), KV2 FROM " + tableName + " WHERE PHOENIX_ROW_TIMESTAMP() < PK2 "; try (Statement stmt = conn.createStatement()) { @@ -335,7 +336,7 @@ public void testRowTimestampFunctionAndAdditionalColsWithLessThanPredicate() thr public void testRowTimestampFunctionOnlyWithGreaterThanPredicate() throws Exception { long rowTimestamp = EnvironmentEdgeManager.currentTimeMillis() - TS_OFFSET; String tableName = createTestData(rowTimestamp, NUM_ROWS); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String sql = "SELECT PHOENIX_ROW_TIMESTAMP() FROM " + tableName + " WHERE PHOENIX_ROW_TIMESTAMP() > PK2 "; try (Statement stmt = conn.createStatement()) { @@ -358,7 +359,7 @@ public void testRowTimestampFunctionOnlyWithGreaterThanPredicate() throws Except public void testRowTimestampFunctionAndColsWithGreaterThanPredicate() throws Exception { long rowTimestamp = EnvironmentEdgeManager.currentTimeMillis() - TS_OFFSET; String tableName = createTestData(rowTimestamp, NUM_ROWS); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String sql = "SELECT PHOENIX_ROW_TIMESTAMP(), KV1 FROM " + tableName + " WHERE PHOENIX_ROW_TIMESTAMP() > PK2 "; try (Statement stmt = conn.createStatement()) { @@ -383,7 +384,7 @@ public void testRowTimestampFunctionAndColsWithGreaterThanPredicate() throws Exc public void testSimpleSelectColsWithPhoenixRowTimestampPredicate() throws Exception { long rowTimestamp = EnvironmentEdgeManager.currentTimeMillis() - TS_OFFSET; String tableName = createTestData(rowTimestamp, NUM_ROWS); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String sql = "SELECT KV1 FROM " + tableName + " WHERE PHOENIX_ROW_TIMESTAMP() > PK2 "; try (Statement stmt = conn.createStatement()) { @@ -407,7 +408,7 @@ public void testSimpleSelectColsWithPhoenixRowTimestampPredicate() throws Except public void testSelectCountWithPhoenixRowTimestampPredicate() throws Exception { long rowTimestamp = EnvironmentEdgeManager.currentTimeMillis() - TS_OFFSET; String tableName = createTestData(rowTimestamp, NUM_ROWS); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String sql = "SELECT COUNT(*) FROM " + tableName + " WHERE PHOENIX_ROW_TIMESTAMP() > PK2 "; try (Statement stmt = conn.createStatement()) { @@ -427,7 +428,7 @@ public void testSelectCountWithPhoenixRowTimestampPredicate() throws Exception { public void testSelectWithMultiplePredicates() throws Exception { long rowTimestamp = EnvironmentEdgeManager.currentTimeMillis() - TS_OFFSET; String tableName = createTestData(rowTimestamp, NUM_ROWS); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String sql = "SELECT COUNT(*) FROM " + tableName + " WHERE PHOENIX_ROW_TIMESTAMP() > PK2 AND KV1 = 'KV1_1'"; try (Statement stmt = conn.createStatement()) { @@ -448,7 +449,7 @@ public void testSelectWithMultiplePredicates() throws Exception { public void testTimestampComparePredicate() throws Exception { long rowTimestamp = EnvironmentEdgeManager.currentTimeMillis() - TS_OFFSET; String tableName = createTestData(rowTimestamp, NUM_ROWS); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES))) { try (Statement stmt = conn.createStatement()) { String sql = "SELECT COUNT(*) FROM " + tableName + " WHERE ((PHOENIX_ROW_TIMESTAMP() > PK2) AND " + @@ -486,7 +487,7 @@ public void testPhoenixRowTimestampWhenAggShouldFail() throws Exception { } long rowTimestamp = EnvironmentEdgeManager.currentTimeMillis() - TS_OFFSET; String tableName = createTestData(rowTimestamp, NUM_ROWS); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES))) { try (Statement stmt = conn.createStatement()) { String sql = "SELECT PHOENIX_ROW_TIMESTAMP(), PK1, COUNT(*) FROM " + tableName + " WHERE ((PHOENIX_ROW_TIMESTAMP() > PK2) AND " + @@ -504,7 +505,7 @@ public void testPhoenixRowTimestampWhenAggShouldFail() throws Exception { @Test public void testPhoenixRowTimestampWithWildcard() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String dataTableName = generateUniqueName(); conn.createStatement().execute("create table " + dataTableName + " (pk1 integer not null primary key, x.v1 float, y.v2 float, z.v3 float)" + this.tableDDLOptions); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixRuntimeIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixRuntimeIT.java index e494b4f81d9..94f0ccbbca1 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixRuntimeIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixRuntimeIT.java @@ -18,6 +18,7 @@ package org.apache.phoenix.end2end; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertEquals; @@ -46,6 +47,7 @@ import org.apache.phoenix.expression.Expression; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.schema.PTableType; import org.apache.phoenix.schema.tuple.ResultTuple; import org.apache.phoenix.schema.types.PVarchar; @@ -57,7 +59,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; import org.apache.phoenix.thirdparty.com.google.common.collect.Sets; - @Category(ParallelStatsDisabledTest.class) public class PhoenixRuntimeIT extends ParallelStatsDisabledIT { private static void assertTenantIds(Expression e, Table htable, Filter filter, String[] tenantIds) throws IOException { @@ -90,10 +91,10 @@ public void testGetTenantIdExpressionForUnsaltedTable() throws Exception { @Test public void testGenererateColumnInfoTenantTable() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.setAutoCommit(true); conn.createStatement().execute("CREATE TABLE MULTITENANT_TABLE (TENANT_ID VARCHAR NOT NULL, GLOBAL_COL1 VARCHAR, GLOBAL_COL2 VARCHAR CONSTRAINT pk PRIMARY KEY (TENANT_ID, GLOBAL_COL1)) MULTI_TENANT=true"); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, "MyTenantId"); Connection tconn = DriverManager.getConnection(getUrl(), props); tconn.setAutoCommit(true); @@ -119,7 +120,7 @@ private static Filter getUserTableAndViewsFilter() { } private void testGetTenantIdExpression(boolean isSalted) throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.setAutoCommit(true); String tableName = generateUniqueName() ; String sequenceName = generateUniqueName(); @@ -130,22 +131,22 @@ private void testGetTenantIdExpression(boolean isSalted) throws Exception { conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES('" + t1 + "','x')"); conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES('" + t2 + "','y')"); - Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, t1); Connection tsconn = DriverManager.getConnection(getUrl(), props); tsconn.createStatement().execute("CREATE SEQUENCE " + sequenceName); Expression e1 = PhoenixRuntime.getTenantIdExpression(tsconn, PhoenixDatabaseMetaData.SYSTEM_SEQUENCE_NAME); - Table htable1 = tsconn.unwrap(PhoenixConnection.class).getQueryServices().getTable(PhoenixDatabaseMetaData.SYSTEM_SEQUENCE_NAME_BYTES); + Table htable1 = tsconn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getTable(PhoenixDatabaseMetaData.SYSTEM_SEQUENCE_NAME_BYTES); assertTenantIds(e1, htable1, new FirstKeyOnlyFilter(), new String[] {"", t1} ); String viewName = generateUniqueName(); tsconn.createStatement().execute("CREATE VIEW " + viewName + "(V1 VARCHAR) AS SELECT * FROM " + tableName); Expression e2 = PhoenixRuntime.getTenantIdExpression(tsconn, PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME); - Table htable2 = conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME_BYTES); + Table htable2 = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getTable(PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME_BYTES); assertTenantIds(e2, htable2, getUserTableAndViewsFilter(), new String[] {"", t1} ); Expression e3 = PhoenixRuntime.getTenantIdExpression(conn, tableName); - Table htable3 = conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(Bytes.toBytes(tableName)); + Table htable3 = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getTable(Bytes.toBytes(tableName)); assertTenantIds(e3, htable3, new FirstKeyOnlyFilter(), new String[] {t1, t2} ); String basTableName = generateUniqueName(); @@ -156,13 +157,13 @@ private void testGetTenantIdExpression(boolean isSalted) throws Exception { String indexName1 = generateUniqueName(); tsconn.createStatement().execute("CREATE INDEX " + indexName1 + " ON " + viewName + "(V1)"); Expression e5 = PhoenixRuntime.getTenantIdExpression(tsconn, indexName1); - Table htable5 = tsconn.unwrap(PhoenixConnection.class).getQueryServices().getTable(Bytes.toBytes(MetaDataUtil.VIEW_INDEX_TABLE_PREFIX + tableName)); + Table htable5 = tsconn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getTable(Bytes.toBytes(MetaDataUtil.VIEW_INDEX_TABLE_PREFIX + tableName)); assertTenantIds(e5, htable5, new FirstKeyOnlyFilter(), new String[] {t1} ); String indexName2 = generateUniqueName(); conn.createStatement().execute("CREATE INDEX " + indexName2 + " ON " + tableName + "(k2)"); Expression e6 = PhoenixRuntime.getTenantIdExpression(conn, indexName2); - Table htable6 = conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(Bytes.toBytes(indexName2)); + Table htable6 = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getTable(Bytes.toBytes(indexName2)); assertTenantIds(e6, htable6, new FirstKeyOnlyFilter(), new String[] {t1, t2} ); tableName = generateUniqueName() + "BAR_" + (isSalted ? "SALTED" : "UNSALTED"); @@ -170,7 +171,7 @@ private void testGetTenantIdExpression(boolean isSalted) throws Exception { conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES('" + t1 + "','x')"); conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES('" + t2 + "','y')"); Expression e7 = PhoenixRuntime.getFirstPKColumnExpression(conn, tableName); - Table htable7 = conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(Bytes.toBytes(tableName)); + Table htable7 = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getTable(Bytes.toBytes(tableName)); assertTenantIds(e7, htable7, new FirstKeyOnlyFilter(), new String[] {t1, t2} ); } } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixTTLToolIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixTTLToolIT.java index d27cea12d6a..5d5b63d10c5 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixTTLToolIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixTTLToolIT.java @@ -17,6 +17,8 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import org.apache.hadoop.conf.Configuration; @@ -32,8 +34,11 @@ import org.apache.phoenix.coprocessor.BaseScannerRegionObserver; import org.apache.phoenix.mapreduce.PhoenixTTLTool; import org.apache.phoenix.mapreduce.util.PhoenixMultiInputUtil; +import org.apache.phoenix.query.BaseTest; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; +import org.apache.phoenix.util.InstanceResolver; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.util.TestUtil; @@ -63,7 +68,6 @@ import org.apache.phoenix.query.ConfigurationFactory; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; -import org.apache.phoenix.util.InstanceResolver; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.util.TestUtil; @@ -85,19 +89,22 @@ public static synchronized void doSetup() throws Exception { props.put(BaseScannerRegionObserverConstants.PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY, Integer.toString(60*60)); // An hour props.put(QueryServices.USE_STATS_FOR_PARALLELIZATION, Boolean.toString(false)); props.put(QueryServices.PHOENIX_TTL_SERVER_SIDE_MASKING_ENABLED, Boolean.toString(true)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); - + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } InstanceResolver.clearSingletons(); // Make sure the ConnectionInfo in the tool doesn't try to pull a default Configuration InstanceResolver.getSingleton(ConfigurationFactory.class, new ConfigurationFactory() { @Override public Configuration getConfiguration() { - return new Configuration(config); + return new Configuration(BaseTest.getConfiguration()); } @Override public Configuration getConfiguration(Configuration confToClone) { - Configuration copy = new Configuration(config); + Configuration copy = new Configuration(BaseTest.getConfiguration()); copy.addResource(confToClone); return copy; } @@ -123,7 +130,7 @@ public Configuration getConfiguration(Configuration confToClone) { private void verifyNumberOfRowsFromHBaseLevel(String tableName, String regrex, int expectedRows) throws Exception { - try (Table table = driver.getConnectionQueryServices(getUrl(), TestUtil.TEST_PROPERTIES) + try (Table table = driver.getConnectionQueryServices(getActiveUrl(), TEST_PROPERTIES) .getTable(SchemaUtil.getTableNameAsBytes( SchemaUtil.getSchemaNameFromFullName(tableName), SchemaUtil.getTableNameFromFullName(tableName)))) { @@ -190,11 +197,11 @@ public void testTenantViewOnGlobalViewWithMoreThanOneIndex() throws Exception { String tenantView2 = schema + "." + generateUniqueName(); String indexTable = "_IDX_" + baseTableFullName; - try (Connection globalConn = DriverManager.getConnection(getUrl()); + try (Connection globalConn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenant1Connection = - PhoenixMultiInputUtil.buildTenantConnection(getUrl(), tenant1); + PhoenixMultiInputUtil.buildTenantConnection(PropertiesUtil.deepCopy(TEST_PROPERTIES), getUrl(), tenant1); Connection tenant2Connection = - PhoenixMultiInputUtil.buildTenantConnection(getUrl(), tenant2)) { + PhoenixMultiInputUtil.buildTenantConnection(PropertiesUtil.deepCopy(TEST_PROPERTIES), getUrl(), tenant2)) { createMultiTenantTable(globalConn, baseTableFullName); globalConn.createStatement().execute(String.format(VIEW_DDL_WITH_ID_PREFIX_AND_TTL, @@ -265,11 +272,11 @@ public void testGlobalViewWithMoreThanOneIndex() throws Exception { String tenant1 = generateUniqueName(); String tenant2 = generateUniqueName(); - try (Connection globalConn = DriverManager.getConnection(getUrl()); + try (Connection globalConn = DriverManager.getConnection(getUrl() , PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenant1Connection = - PhoenixMultiInputUtil.buildTenantConnection(getUrl(), tenant1); + PhoenixMultiInputUtil.buildTenantConnection(PropertiesUtil.deepCopy(TEST_PROPERTIES),getUrl(), tenant1); Connection tenant2Connection = - PhoenixMultiInputUtil.buildTenantConnection(getUrl(), tenant2)) { + PhoenixMultiInputUtil.buildTenantConnection(PropertiesUtil.deepCopy(TEST_PROPERTIES), getUrl(), tenant2)) { createMultiTenantTable(globalConn, baseTableFullName); @@ -349,11 +356,11 @@ public void testTenantViewCase() throws Exception { String tenant1 = generateUniqueName(); String tenant2 = generateUniqueName(); - try (Connection globalConn = DriverManager.getConnection(getUrl()); + try (Connection globalConn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenant1Connection = - PhoenixMultiInputUtil.buildTenantConnection(getUrl(), tenant1); + PhoenixMultiInputUtil.buildTenantConnection(PropertiesUtil.deepCopy(TEST_PROPERTIES), getUrl(), tenant1); Connection tenant2Connection = - PhoenixMultiInputUtil.buildTenantConnection(getUrl(), tenant2)) { + PhoenixMultiInputUtil.buildTenantConnection(PropertiesUtil.deepCopy(TEST_PROPERTIES), getUrl(), tenant2)) { createMultiTenantTable(globalConn, baseTableFullName); String ddl = "CREATE VIEW %s (PK1 BIGINT PRIMARY KEY, " + @@ -439,11 +446,11 @@ public void testGlobalViewWithNoIndex() throws Exception { String tenant1 = generateUniqueName(); String tenant2 = generateUniqueName(); - try (Connection globalConn = DriverManager.getConnection(getUrl()); + try (Connection globalConn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenant1Connection = - PhoenixMultiInputUtil.buildTenantConnection(getUrl(), tenant1); + PhoenixMultiInputUtil.buildTenantConnection(PropertiesUtil.deepCopy(TEST_PROPERTIES), getUrl(), tenant1); Connection tenant2Connection = - PhoenixMultiInputUtil.buildTenantConnection(getUrl(), tenant2)) { + PhoenixMultiInputUtil.buildTenantConnection(PropertiesUtil.deepCopy(TEST_PROPERTIES), getUrl(), tenant2)) { createMultiTenantTable(globalConn, baseTableFullName); String ddl = "CREATE VIEW %s (PK1 BIGINT PRIMARY KEY, " + @@ -500,7 +507,7 @@ public void testGlobalViewOnNonMultiTenantTable() throws Exception { String globalViewName1 = schema + "." + generateUniqueName(); String globalViewName2 = schema + "." + generateUniqueName(); - try (Connection globalConn = DriverManager.getConnection(getUrl())) { + try (Connection globalConn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String ddl = "CREATE TABLE " + baseTableFullName + " (ID CHAR(10) NOT NULL PRIMARY KEY, NUM BIGINT)"; globalConn.createStatement().execute(ddl); @@ -559,7 +566,7 @@ public void testGlobalViewOnNonMultiTenantTableWithIndex() throws Exception { String indexTable4 = generateUniqueName() + "_IDX"; String indexTable = "_IDX_" + baseTableFullName; - try (Connection globalConn = DriverManager.getConnection(getUrl())) { + try (Connection globalConn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String ddl = "CREATE TABLE " + baseTableFullName + " (PK1 BIGINT NOT NULL, ID CHAR(10) NOT NULL, NUM BIGINT CONSTRAINT " + "PK PRIMARY KEY (PK1,ID))"; @@ -627,9 +634,9 @@ public void testDeleteByViewAndTenant() throws Exception { String tenantViewName2 = schema + "." + generateUniqueName(); String tenant1 = generateUniqueName(); - try (Connection globalConn = DriverManager.getConnection(getUrl()); + try (Connection globalConn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenant1Connection = - PhoenixMultiInputUtil.buildTenantConnection(getUrl(), tenant1)) { + PhoenixMultiInputUtil.buildTenantConnection(PropertiesUtil.deepCopy(TEST_PROPERTIES), getUrl(), tenant1)) { createMultiTenantTable(globalConn, baseTableFullName); String ddl = "CREATE VIEW %s (PK1 BIGINT PRIMARY KEY, " + @@ -691,11 +698,11 @@ public void testDeleteByTenant() throws Exception { String tenant1 = generateUniqueName(); String tenant2 = generateUniqueName(); - try (Connection globalConn = DriverManager.getConnection(getUrl()); + try (Connection globalConn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenant1Connection = - PhoenixMultiInputUtil.buildTenantConnection(getUrl(), tenant1); + PhoenixMultiInputUtil.buildTenantConnection(PropertiesUtil.deepCopy(TEST_PROPERTIES), getUrl(), tenant1); Connection tenant2Connection = - PhoenixMultiInputUtil.buildTenantConnection(getUrl(), tenant2)) { + PhoenixMultiInputUtil.buildTenantConnection(PropertiesUtil.deepCopy(TEST_PROPERTIES), getUrl(), tenant2)) { createMultiTenantTable(globalConn, baseTableFullName); String ddl = "CREATE VIEW %s (PK1 BIGINT PRIMARY KEY, " + @@ -769,11 +776,11 @@ public void testDeleteByViewName() throws Exception { String tenant1 = generateUniqueName(); String tenant2 = generateUniqueName(); - try (Connection globalConn = DriverManager.getConnection(getUrl()); + try (Connection globalConn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenant1Connection = - PhoenixMultiInputUtil.buildTenantConnection(getUrl(), tenant1); + PhoenixMultiInputUtil.buildTenantConnection(PropertiesUtil.deepCopy(TEST_PROPERTIES), getUrl(), tenant1); Connection tenant2Connection = - PhoenixMultiInputUtil.buildTenantConnection(getUrl(), tenant2)) { + PhoenixMultiInputUtil.buildTenantConnection(PropertiesUtil.deepCopy(TEST_PROPERTIES), getUrl(), tenant2)) { createMultiTenantTable(globalConn, baseTableFullName); String ddl = "CREATE VIEW %s (PK1 BIGINT PRIMARY KEY, " + @@ -845,7 +852,7 @@ public void testCleanMoreThanThreeLevelViewCase() throws Exception { String leafViewName1 = schema + "." + generateUniqueName(); String leafViewName2 = schema + "." + generateUniqueName(); - try (Connection globalConn = DriverManager.getConnection(getUrl())) { + try (Connection globalConn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String baseTableDdl = "CREATE TABLE " + baseTableFullName + " (ID CHAR(10) NOT NULL PRIMARY KEY, NUM BIGINT)"; globalConn.createStatement().execute(baseTableDdl); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PointInTimeQueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PointInTimeQueryIT.java index ba7fa159d76..d63ed42827b 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PointInTimeQueryIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PointInTimeQueryIT.java @@ -43,7 +43,6 @@ import org.junit.experimental.categories.Category; import org.junit.runners.Parameterized.Parameters; - @Category(NeedsOwnMiniClusterTest.class) public class PointInTimeQueryIT extends BaseQueryIT { @@ -95,7 +94,7 @@ public void testPointInTimeDeleteUngroupedAggregation() throws Exception { // Delete row at timestamp 3. This should not be seen by the query executing // Remove column value at ts + 1 (i.e. equivalent to setting the value to null) - try (Connection futureConn = DriverManager.getConnection(getUrl())) { + try (Connection futureConn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { PreparedStatement stmt = futureConn.prepareStatement("delete from " + tableName + " where organization_id=? and entity_id=?"); stmt.setString(1, tenantId); stmt.setString(2, ROW6); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PointInTimeScanQueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PointInTimeScanQueryIT.java index da068aafa47..ded067488e2 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PointInTimeScanQueryIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PointInTimeScanQueryIT.java @@ -45,7 +45,6 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; - @Category(NeedsOwnMiniClusterTest.class) public class PointInTimeScanQueryIT extends BaseQueryIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PowerFunctionEnd2EndIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PowerFunctionEnd2EndIT.java index 13a24385e43..a9174e077c7 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PowerFunctionEnd2EndIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PowerFunctionEnd2EndIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.apache.phoenix.util.TestUtil.closeStmtAndConn; import static org.junit.Assert.assertTrue; @@ -26,6 +27,7 @@ import java.sql.ResultSet; import org.apache.phoenix.expression.function.PowerFunction; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -47,7 +49,7 @@ public void initTable() throws Exception { Connection conn = null; PreparedStatement stmt = null; try { - conn = DriverManager.getConnection(getUrl()); + conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String ddl; ddl = "CREATE TABLE " + signedTableName + " (k VARCHAR NOT NULL PRIMARY KEY, doub DOUBLE, fl FLOAT, inte INTEGER, lon BIGINT, smalli SMALLINT, tinyi TINYINT)"; @@ -125,7 +127,7 @@ private void testNumberSpec(Connection conn, double data, String tableName) thro @Test public void test() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); for (double d : new double[] { 0.0, 1.0, -1.0, 123.1234, -123.1234 }) { testNumberSpec(conn, d, signedTableName); if (d >= 0) testNumberSpec(conn, d, unsignedTableName); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PreMatureTimelyAbortScanIt.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PreMatureTimelyAbortScanIt.java index 4567b280b14..2e00aa2de47 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PreMatureTimelyAbortScanIt.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PreMatureTimelyAbortScanIt.java @@ -21,8 +21,10 @@ import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.iterate.ScanningResultIterator; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.junit.BeforeClass; import org.junit.Test; @@ -35,7 +37,10 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.Map; +import java.util.Properties; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.*; @Category(ParallelStatsDisabledTest.class) public class PreMatureTimelyAbortScanIt extends ParallelStatsDisabledIT { @@ -47,20 +52,23 @@ public static synchronized void doSetup() throws Exception { props.put(BaseScannerRegionObserverConstants.PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY, Integer.toString(60*60)); // An hour props.put(QueryServices.USE_STATS_FOR_PARALLELIZATION, Boolean.toString(false)); props.put(QueryServices.PHOENIX_SERVER_PAGE_SIZE_MS, Integer.toString(0)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } private String getUniqueUrl() { - return url + generateUniqueName(); + return getUrl() + generateUniqueName(); } @Test public void testPreMatureScannerAbortForCount() throws Exception { - - try (Connection conn = DriverManager.getConnection(getUniqueUrl())) { + try (Connection conn = DriverManager.getConnection(getUniqueUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute("CREATE TABLE LONG_BUG (ID INTEGER PRIMARY KEY, AMOUNT DECIMAL) SALT_BUCKETS = 16 "); } - try (Connection conn = DriverManager.getConnection(getUniqueUrl())) { + try (Connection conn = DriverManager.getConnection(getUniqueUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { for (int i = 0; i<100 ; i++) { int amount = -50000 + i; String s = "UPSERT INTO LONG_BUG (ID, AMOUNT) VALUES( " + i + ", " + amount + ")"; @@ -70,7 +78,7 @@ public void testPreMatureScannerAbortForCount() throws Exception { } try { - PhoenixConnection conn = DriverManager.getConnection(getUniqueUrl()).unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection conn = DriverManager.getConnection(getUniqueUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixMonitoredConnection.class); ScanningResultIterator.setIsScannerClosedForcefully(true); ResultSet resultSet = conn.createStatement().executeQuery( "SELECT COUNT(*) FROM LONG_BUG WHERE ID % 2 = 0"); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PreStoreScannerOpenIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PreStoreScannerOpenIT.java index 1da0c89c2a5..c34c1c4f8a3 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PreStoreScannerOpenIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PreStoreScannerOpenIT.java @@ -38,6 +38,7 @@ import org.apache.phoenix.util.EnvironmentEdgeManager; import org.apache.phoenix.util.ManualEnvironmentEdge; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.junit.Assert; import org.junit.BeforeClass; @@ -50,6 +51,8 @@ import net.bytebuddy.dynamic.loading.ClassReloadingStrategy; import net.bytebuddy.matcher.ElementMatchers; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; @Category(NeedsOwnMiniClusterTest.class) public class PreStoreScannerOpenIT extends BaseTest { @@ -102,7 +105,11 @@ public static void setUp() throws Exception { // Disable compactions props.put(CompactSplit.HBASE_REGION_SERVER_ENABLE_COMPACTION, "false"); props.put("hbase.procedure.remote.dispatcher.delay.msec", "0"); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } /** @@ -115,9 +122,8 @@ public static void setUp() throws Exception { @Test public void testStoreScannerNotDoingExtraSeeks() throws Exception { createTable(TABLE_NAME); - - try (Connection conn = DriverManager.getConnection(getUrl()); - Statement stmt = conn.createStatement()) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Statement stmt = conn.createStatement()) { stmt.execute("UPSERT INTO " + TABLE_NAME + " (id, col1) VALUES (1, 'a')"); stmt.execute("UPSERT INTO " + TABLE_NAME + " (id, col1) VALUES (10, 'b')"); conn.commit(); @@ -134,8 +140,7 @@ public void testStoreScannerNotDoingExtraSeeks() throws Exception { } Assert.assertEquals(2, getStoreFileCount(TABLE_NAME)); - - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { ResultSet rs = stmt.executeQuery("SELECT col1 FROM " + TABLE_NAME + " WHERE id = 3"); Assert.assertTrue(rs.next()); @@ -157,7 +162,7 @@ public void testSCNScansCanSeeDeletedRows() throws Exception { createTable(tableName); long beforeRowWasDeleted; - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.execute("UPSERT INTO " + tableName + " (id, col1) VALUES (1, 'a')"); conn.commit(); @@ -178,7 +183,7 @@ public void testSCNScansCanSeeDeletedRows() throws Exception { Assert.assertFalse(rs.next()); } - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(beforeRowWasDeleted)); try (Connection conn = DriverManager.getConnection(getUrl(), props); Statement stmt = conn.createStatement()) { @@ -202,8 +207,7 @@ public void testRowsAreNotExpiredPartially() throws Exception { ManualEnvironmentEdge injectEdge = new ManualEnvironmentEdge(); injectEdge.setValue(EnvironmentEdgeManager.currentTimeMillis()); EnvironmentEdgeManager.injectEdge(injectEdge); - - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.execute("UPSERT INTO " + tableName + " (id, col1, col2) VALUES (1, 'a', 'ab')"); conn.commit(); @@ -231,7 +235,7 @@ public void testRowsAreNotExpiredPartially() throws Exception { } private void createTable(String tableName) throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.execute("CREATE TABLE " + tableName + " (id INTEGER PRIMARY KEY, col1 VARCHAR, col2 VARCHAR) BLOOMFILTER = NONE, TTL = " diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PrimitiveTypeIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PrimitiveTypeIT.java index 49616b17c03..fee02a47361 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PrimitiveTypeIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PrimitiveTypeIT.java @@ -32,7 +32,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class PrimitiveTypeIT extends ParallelStatsDisabledIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProductMetricsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProductMetricsIT.java index 6a99671ba44..7445be3144d 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProductMetricsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProductMetricsIT.java @@ -40,6 +40,7 @@ import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.QueryConstants; import org.apache.phoenix.schema.types.PDate; import org.apache.phoenix.util.ByteUtil; @@ -51,7 +52,6 @@ import org.apache.phoenix.thirdparty.com.google.common.collect.Lists; import org.apache.phoenix.thirdparty.com.google.common.collect.Ordering; - @Category(ParallelStatsDisabledTest.class) public class ProductMetricsIT extends ParallelStatsDisabledIT { private static final String PRODUCT_METRICS_NAME = "PRODUCT_METRICS"; @@ -1527,7 +1527,7 @@ public void testFilterOnTrailingKeyColumn() throws Exception { Admin admin = null; try { initTableValues(tablename, tenantId, getSplits(tenantId)); - admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin(); + admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin(); admin.flush(TableName.valueOf(SchemaUtil.getTableNameAsBytes(PRODUCT_METRICS_SCHEMA_NAME,tablename))); String query = "SELECT SUM(TRANSACTIONS) FROM " + tablename + " WHERE FEATURE=?"; PreparedStatement statement = conn.prepareStatement(query); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProjectArrayElemAfterHashJoinIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProjectArrayElemAfterHashJoinIT.java index ae18506e297..a75c56f6dc2 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProjectArrayElemAfterHashJoinIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProjectArrayElemAfterHashJoinIT.java @@ -33,7 +33,6 @@ import org.apache.phoenix.util.QueryUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class ProjectArrayElemAfterHashJoinIT extends ParallelStatsDisabledIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PropertiesInSyncIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PropertiesInSyncIT.java index fde6e3515f0..827460cadf3 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PropertiesInSyncIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PropertiesInSyncIT.java @@ -29,6 +29,7 @@ import org.apache.phoenix.coprocessor.BaseScannerRegionObserver; import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.LiteralTTLExpression; import org.apache.phoenix.schema.PName; @@ -37,7 +38,7 @@ import org.apache.phoenix.schema.TTLExpression; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; import org.apache.phoenix.util.MetaDataUtil; -import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; import org.junit.BeforeClass; @@ -54,6 +55,8 @@ import java.util.Properties; import java.util.Set; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import static org.apache.phoenix.coprocessorclient.BaseScannerRegionObserverConstants.PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY; @@ -92,13 +95,16 @@ public static synchronized void doSetup() throws Exception { Map props = Maps.newHashMapWithExpectedSize(1); props.put(PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY, Integer.toString(60*60)); // An hour props.put(QueryServices.USE_STATS_FOR_PARALLELIZATION, Boolean.toString(false)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); - } + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } // Test that we disallow specifying synced properties to be set per column family when creating a table @Test public void testDisallowSyncedPropsToBeSetColFamSpecificCreateTable() throws Exception { - Connection conn = DriverManager.getConnection(getUrl(), new Properties()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); for (String propName: SYNCED_DATA_TABLE_AND_INDEX_COL_FAM_PROPERTIES) { try { @@ -118,7 +124,7 @@ public void testDisallowSyncedPropsToBeSetColFamSpecificCreateTable() throws Exc // Test that all column families have the same value of synced properties when creating a table @Test public void testSyncedPropsAllColFamsCreateTable() throws Exception { - Connection conn = DriverManager.getConnection(getUrl(), new Properties()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = createBaseTableWithProps(conn); verifyHBaseColumnFamilyProperties(tableName, conn, false, false); conn.close(); @@ -127,7 +133,7 @@ public void testSyncedPropsAllColFamsCreateTable() throws Exception { // Test that we disallow specifying synced properties to be set when creating an index on a physical table or a view @Test public void testDisallowSyncedPropsToBeSetCreateIndex() throws Exception { - Connection conn = DriverManager.getConnection(getUrl(), new Properties()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = createBaseTableWithProps(conn); String localIndexName = tableName + "_LOCAL_IDX"; String globalIndexName = tableName + "_GLOBAL_IDX"; @@ -168,7 +174,7 @@ public void testDisallowSyncedPropsToBeSetCreateIndex() throws Exception { // Test that indexes have the same value of synced properties as their base table @Test public void testSyncedPropsBaseTableCreateIndex() throws Exception { - Connection conn = DriverManager.getConnection(getUrl(), new Properties()); + Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = createBaseTableWithProps(conn); createIndexTable(conn, tableName, PTable.IndexType.LOCAL).getSecond(); String globalIndexName = createIndexTable(conn, tableName, PTable.IndexType.GLOBAL).getSecond(); @@ -182,7 +188,7 @@ public void testSyncedPropsBaseTableCreateIndex() throws Exception { // Test that the physical view index table has the same value of synced properties as its base table @Test public void testSyncedPropsBaseTableCreateViewIndex() throws Exception { - Connection conn = DriverManager.getConnection(getUrl(), new Properties()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = createBaseTableWithProps(conn); String viewIndexName = createIndexTable(conn, tableName, null).getSecond(); @@ -194,7 +200,7 @@ public void testSyncedPropsBaseTableCreateViewIndex() throws Exception { // Test that we disallow specifying synced properties to be set per column family when altering a table @Test public void testDisallowSyncedPropsToBeSetColFamSpecificAlterTable() throws Exception { - Connection conn = DriverManager.getConnection(getUrl(), new Properties()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = createBaseTableWithProps(conn); StringBuilder alterAllSyncedPropsString = new StringBuilder(); String modPropString = COL_FAM1 + ".%s=" + DUMMY_PROP_VALUE + ","; @@ -225,7 +231,7 @@ public void testDisallowSyncedPropsToBeSetColFamSpecificAlterTable() throws Exce // Test that any alteration of the synced properties gets propagated to all indexes and the physical view index table @Test public void testAlterSyncedPropsPropagateToAllIndexesAndViewIndex() throws Exception { - Connection conn = DriverManager.getConnection(getUrl(), new Properties()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = createBaseTableWithProps(conn); Set tablesToCheck = new HashSet<>(); tablesToCheck.add(tableName); @@ -256,7 +262,7 @@ public void testAlterSyncedPropsPropagateToAllIndexesAndViewIndex() throws Excep // Test that any if we add a column family to a base table, it gets the synced properties @Test public void testAlterTableAddColumnFamilyGetsSyncedProps() throws Exception { - Connection conn = DriverManager.getConnection(getUrl(), new Properties()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = createBaseTableWithProps(conn); // Test that we are not allowed to set any property to be kept in sync, specific to the new column family to be added @@ -295,7 +301,7 @@ public void testAlterTableAddColumnFamilyGetsSyncedProps() throws Exception { for (String table: tablesToCheck) { verifyHBaseColumnFamilyProperties(table, conn, true, true); } - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { ColumnFamilyDescriptor[] columnFamilies = admin.getDescriptor(TableName.valueOf(tableName)) .getColumnFamilies(); for (ColumnFamilyDescriptor cfd: columnFamilies) { @@ -314,7 +320,7 @@ public void testAlterTableAddColumnFamilyGetsSyncedProps() throws Exception { // Test that we disallow altering a synced property for a global index table @Test public void testDisallowAlterGlobalIndexTable() throws Exception { - Connection conn = DriverManager.getConnection(getUrl(), new Properties()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = createBaseTableWithProps(conn); String globalIndexName = createIndexTable(conn, tableName, PTable.IndexType.GLOBAL).getSecond(); for (String propName: SYNCED_DATA_TABLE_AND_INDEX_COL_FAM_PROPERTIES) { @@ -334,7 +340,7 @@ public void testDisallowAlterGlobalIndexTable() throws Exception { // may have tables which have column families and indexes whose properties are out of sync @Test public void testOldClientSyncPropsUpgradePath() throws Exception { - Connection conn = DriverManager.getConnection(getUrl(), new Properties()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String baseTableName = createBaseTableWithProps(conn); String baseTableName1 = createBaseTableWithProps(conn); @@ -360,7 +366,7 @@ public void testOldClientSyncPropsUpgradePath() throws Exception { final ColumnFamilyDescriptor defaultCF; if (MetaDataUtil.isViewIndex(tableName)) { // We won't be able to get the PTable for a view index table - tableDescriptor = conn.unwrap(PhoenixConnection.class).getQueryServices() + tableDescriptor = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices() .getTableDescriptor(Bytes.toBytes(tableName)); defaultCF = tableDescriptor.getColumnFamily(DEFAULT_COLUMN_FAMILY_BYTES); } else { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryDatabaseMetaDataIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryDatabaseMetaDataIT.java index 2549517fd0d..3a16f0a2b02 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryDatabaseMetaDataIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryDatabaseMetaDataIT.java @@ -66,6 +66,7 @@ import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.schema.ColumnNotFoundException; import org.apache.phoenix.schema.PTable.ViewType; import org.apache.phoenix.schema.PTableType; @@ -82,7 +83,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class QueryDatabaseMetaDataIT extends ParallelStatsDisabledIT { @@ -104,7 +104,7 @@ private static void createMDTestTable(Connection conn, String tableName, String @Before // We need to clean up phoenix metadata to ensure tests don't step on each other public void deleteMetadata() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String delete = "DELETE FROM SYSTEM.CATALOG WHERE TABLE_SCHEM IS NULL OR TABLE_SCHEM = '' OR TABLE_SCHEM != 'SYSTEM'"; conn.createStatement().executeUpdate(delete); @@ -112,7 +112,7 @@ public void deleteMetadata() throws Exception { delete = "DELETE FROM \"SYSTEM\".\"SEQUENCE\""; conn.createStatement().executeUpdate(delete); conn.commit(); - conn.unwrap(PhoenixConnection.class).getQueryServices().clearCache(); + conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().clearCache(); } } @@ -120,14 +120,14 @@ public void deleteMetadata() throws Exception { public void testMetadataTenantSpecific() throws SQLException { // create multi-tenant table String tableName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String baseTableDdl = "CREATE TABLE %s (K1 VARCHAR NOT NULL, K2 VARCHAR NOT NULL, V VARCHAR CONSTRAINT PK PRIMARY KEY(K1, K2)) MULTI_TENANT=true"; conn.createStatement().execute(String.format(baseTableDdl, tableName)); } // create tenant specific view and execute metdata data call with tenant specific connection String tenantId = generateUniqueName(); - Properties tenantProps = new Properties(); + Properties tenantProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); try (Connection tenantConn = DriverManager.getConnection(getUrl(), tenantProps)) { String viewName = generateUniqueName(); @@ -156,7 +156,7 @@ public void testTableMetadataScan() throws SQLException { ensureTableCreated(getUrl(), tableCSchema + "." + tableC, CUSTOM_ENTITY_DATA_FULL_NAME, null); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { DatabaseMetaData dbmd = conn.getMetaData(); ResultSet rs = dbmd.getTables(null, tableASchema, tableAName, null); assertTrue(rs.next()); @@ -261,7 +261,7 @@ public void testTableMetadataScan() throws SQLException { @Test public void testTableTypes() throws SQLException { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { DatabaseMetaData dbmd = conn.getMetaData(); ResultSet rs = dbmd.getTableTypes(); assertTrue(rs.next()); @@ -282,7 +282,7 @@ public void testTableTypes() throws SQLException { @Test public void testSequenceMetadataScan() throws SQLException { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String schema1 = "B" + generateUniqueName(); String seq1 = generateUniqueName(); String seq1FullName = schema1 + "." + seq1; @@ -391,7 +391,7 @@ public void testSequenceMetadataScan() throws SQLException { @Test public void testShowSchemas() throws SQLException { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { ResultSet rs = conn.prepareStatement("show schemas").executeQuery(); assertTrue(rs.next()); assertEquals("SYSTEM", rs.getString("TABLE_SCHEM")); @@ -422,7 +422,7 @@ public void testShowSchemas() throws SQLException { @Test public void testShowTables() throws SQLException { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { // List all the tables in a particular schema. ResultSet rs = conn.prepareStatement("show tables in SYSTEM").executeQuery(); Set tables = new HashSet<>(); @@ -451,7 +451,7 @@ public void testSchemaMetadataScan() throws SQLException { ensureTableCreated(getUrl(), fullTable1, CUSTOM_ENTITY_DATA_FULL_NAME, null); String fullTable2 = generateUniqueName(); ensureTableCreated(getUrl(), fullTable2, PTSDB_NAME, null); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { DatabaseMetaData dbmd = conn.getMetaData(); ResultSet rs; rs = dbmd.getSchemas(null, schema1); @@ -489,7 +489,7 @@ public void testSchemaMetadataScan() throws SQLException { @Test public void testColumnMetadataScan() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String table = generateUniqueName(); createMDTestTable(conn, table, ""); DatabaseMetaData dbmd = conn.getMetaData(); @@ -684,7 +684,7 @@ public void testColumnMetadataScan() throws SQLException { @Test public void testPrimaryKeyMetadataScan() throws SQLException { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String table1 = generateUniqueName(); createMDTestTable(conn, table1, ""); String schema2 = generateUniqueName(); @@ -804,7 +804,7 @@ public void testPrimaryKeyMetadataScan() throws SQLException { @Test public void testMultiTableColumnsMetadataScan() throws SQLException { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String table1 = "TEST" + generateUniqueName(); String table2 = "TEST" + generateUniqueName(); createGroupByTestTable(conn, table1); @@ -868,8 +868,8 @@ public void testMultiTableColumnsMetadataScan() throws SQLException { @Test public void testCreateOnExistingTable() throws Exception { - try (PhoenixConnection pconn = - DriverManager.getConnection(getUrl()).unwrap(PhoenixConnection.class)) { + try (PhoenixMonitoredConnection pconn = + DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixMonitoredConnection.class)) { String tableName = generateUniqueName();// MDTEST_NAME; String schemaName = "";// MDTEST_SCHEMA_NAME; byte[] cfA = Bytes.toBytes(SchemaUtil.normalizeIdentifier("a")); @@ -948,9 +948,9 @@ public void testCreateOnExistingTable() throws Exception { @SuppressWarnings("deprecation") @Test public void testCreateViewOnExistingTable() throws Exception { - try (PhoenixConnection pconn = + try (PhoenixMonitoredConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)) - .unwrap(PhoenixConnection.class)) { + .unwrap(PhoenixMonitoredConnection.class)) { String tableName = generateUniqueName();// MDTEST_NAME; String schemaName = "";// MDTEST_SCHEMA_NAME; byte[] cfB = Bytes.toBytes(SchemaUtil.normalizeIdentifier("b")); @@ -1072,7 +1072,7 @@ public void testAddKVColumnToExistingFamily() throws Throwable { String tableName = generateUniqueName(); initATableValues(tableName, tenantId, getDefaultSplits(tenantId), null, null, getUrl(), null); - try (Connection conn1 = DriverManager.getConnection(getUrl())) { + try (Connection conn1 = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn1.createStatement() .executeUpdate("ALTER TABLE " + tableName + " ADD z_integer integer"); String query = "SELECT z_integer FROM " + tableName; @@ -1086,7 +1086,7 @@ public void testAddKVColumnToNewFamily() throws Exception { String tableName = initATableValues(null, tenantId, getDefaultSplits(tenantId), null, null, getUrl(), null); - try (Connection conn1 = DriverManager.getConnection(getUrl())) { + try (Connection conn1 = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn1.createStatement() .executeUpdate("ALTER TABLE " + tableName + " ADD newcf.z_integer integer"); String query = "SELECT z_integer FROM " + tableName; @@ -1100,7 +1100,7 @@ public void testAddPKColumn() throws Exception { String tableName = initATableValues(null, tenantId, getDefaultSplits(tenantId), null, null, getUrl(), null); - try (Connection conn1 = DriverManager.getConnection(getUrl())) { + try (Connection conn1 = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { try { conn1.createStatement().executeUpdate( "ALTER TABLE " + tableName + " ADD z_string varchar not null primary key"); @@ -1122,7 +1122,7 @@ public void testDropKVColumn() throws Exception { String tableName = initATableValues(null, tenantId, getDefaultSplits(tenantId), null, null, getUrl(), null); - try (Connection conn5 = DriverManager.getConnection(getUrl())) { + try (Connection conn5 = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { assertTrue(conn5.createStatement() .executeQuery("SELECT 1 FROM " + tableName + " WHERE b_string IS NOT NULL") .next()); @@ -1151,7 +1151,7 @@ public void testDropPKColumn() throws Exception { String tableName = initATableValues(generateUniqueName(), tenantId, getDefaultSplits(tenantId), null, null, getUrl(), null); - try (Connection conn1 = DriverManager.getConnection(getUrl())) { + try (Connection conn1 = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn1.createStatement() .executeUpdate("ALTER TABLE " + tableName + " DROP COLUMN entity_id"); fail(); @@ -1192,7 +1192,7 @@ public void testDropAllKVCols() throws Exception { @Test public void testTableWithScemaMetadataScan() throws SQLException { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String table1 = generateUniqueName(); String schema1 = generateUniqueName(); String fullTable1 = schema1 + "." + table1; @@ -1233,7 +1233,7 @@ public void testTableWithScemaMetadataScan() throws SQLException { @Test public void testRemarkColumn() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); // Retrieve the database metadata DatabaseMetaData dbmd = conn.getMetaData(); ResultSet rs = dbmd.getColumns(null, null, null, null); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryExecWithoutSCNIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryExecWithoutSCNIT.java index 0e2b9225abc..d4240ee6ba4 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryExecWithoutSCNIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryExecWithoutSCNIT.java @@ -19,6 +19,7 @@ import static org.apache.phoenix.util.TestUtil.B_VALUE; import static org.apache.phoenix.util.TestUtil.C_VALUE; +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; @@ -29,10 +30,10 @@ import java.sql.ResultSet; import java.util.Properties; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class QueryExecWithoutSCNIT extends ParallelStatsDisabledIT { @Test @@ -40,7 +41,7 @@ public void testScanNoSCN() throws Exception { String tenantId = getOrganizationId(); String tableName = initATableValues(tenantId, getDefaultSplits(tenantId), null, null, getUrl()); String query = "SELECT a_string, b_string FROM " + tableName + " WHERE organization_id=? and a_integer = 5"; - Properties props = new Properties(); // Test with no CurrentSCN property set + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); // Test with no CurrentSCN property set Connection conn = DriverManager.getConnection(getUrl(), props); try { PreparedStatement statement = conn.prepareStatement(query); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryLoggerIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryLoggerIT.java index 7f780305971..81137883fac 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryLoggerIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryLoggerIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.BIND_PARAMETERS; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CLIENT_IP; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.EXCEPTION_TRACE; @@ -32,6 +33,7 @@ import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_LOG_TABLE; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TENANT_ID; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.USER; +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; @@ -50,6 +52,7 @@ import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixDriver; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixResultSet; import org.apache.phoenix.log.LogLevel; import org.apache.phoenix.log.QueryLogger; @@ -58,18 +61,21 @@ import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.util.EnvironmentEdge; import org.apache.phoenix.util.EnvironmentEdgeManager; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.QueryUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; - +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @Category(NeedsOwnMiniClusterTest.class) public class QueryLoggerIT extends BaseTest { + private static final Logger log = LoggerFactory.getLogger(QueryLoggerIT.class); @BeforeClass public static synchronized void doSetup() throws Exception { Map props = Maps.newHashMapWithExpectedSize(1); @@ -77,7 +83,11 @@ public static synchronized void doSetup() throws Exception { props.put(QueryServices.COLLECT_REQUEST_LEVEL_METRICS, String.valueOf(true)); // disable renewing leases as this will force spooling to happen. props.put(QueryServices.RENEW_LEASE_ENABLED, String.valueOf(false)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()), new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } // need the non-test driver for some tests that check number of hconnections, etc. DriverManager.registerDriver(PhoenixDriver.INSTANCE); } @@ -100,10 +110,10 @@ public long currentTime() { public void testDebugLogs() throws Exception { String tableName = generateUniqueName(); createTableAndInsertValues(tableName, true); - Properties props= new Properties(); + Properties props= PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.LOG_LEVEL, LogLevel.DEBUG.name()); Connection conn = DriverManager.getConnection(getUrl(),props); - assertEquals(conn.unwrap(PhoenixConnection.class).getLogLevel(),LogLevel.DEBUG); + assertEquals(conn.unwrap(PhoenixMonitoredConnection.class).getLogLevel(),LogLevel.DEBUG); String query = "SELECT * FROM " + tableName; StatementContext context; try (ResultSet rs = conn.createStatement().executeQuery(query)) { @@ -152,11 +162,11 @@ public void testDebugLogs() throws Exception { public void testLogSampling() throws Exception { String tableName = generateUniqueName(); createTableAndInsertValues(tableName, true); - Properties props= new Properties(); + Properties props= PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.LOG_LEVEL, LogLevel.DEBUG.name()); props.setProperty(QueryServices.LOG_SAMPLE_RATE, "0.5"); Connection conn = DriverManager.getConnection(getUrl(),props); - assertEquals(conn.unwrap(PhoenixConnection.class).getLogLevel(),LogLevel.DEBUG); + assertEquals(conn.unwrap(PhoenixMonitoredConnection.class).getLogLevel(),LogLevel.DEBUG); String query = "SELECT * FROM " + tableName; int count=100; for (int i = 0; i < count; i++) { @@ -187,10 +197,10 @@ public void testLogSampling() throws Exception { public void testInfoLogs() throws Exception{ String tableName = generateUniqueName(); createTableAndInsertValues(tableName, true); - Properties props= new Properties(); + Properties props= PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.LOG_LEVEL, LogLevel.INFO.name()); Connection conn = DriverManager.getConnection(getUrl(),props); - assertEquals(conn.unwrap(PhoenixConnection.class).getLogLevel(),LogLevel.INFO); + assertEquals(conn.unwrap(PhoenixMonitoredConnection.class).getLogLevel(),LogLevel.INFO); String query = "SELECT * FROM " + tableName; StatementContext context; try (ResultSet rs = conn.createStatement().executeQuery(query)) { @@ -231,10 +241,10 @@ public void testInfoLogs() throws Exception{ public void testWithLoggingOFF() throws Exception{ String tableName = generateUniqueName(); createTableAndInsertValues(tableName, true); - Properties props= new Properties(); + Properties props= PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.LOG_LEVEL, LogLevel.OFF.name()); Connection conn = DriverManager.getConnection(getUrl(),props); - assertEquals(conn.unwrap(PhoenixConnection.class).getLogLevel(),LogLevel.OFF); + assertEquals(conn.unwrap(PhoenixMonitoredConnection.class).getLogLevel(),LogLevel.OFF); // delete old data conn.createStatement().executeUpdate("delete from " + SYSTEM_CATALOG_SCHEMA + ".\"" + SYSTEM_LOG_TABLE + "\""); @@ -275,10 +285,10 @@ public void testPreparedStatementWithDebug() throws Exception{ private void testPreparedStatement(LogLevel loglevel) throws Exception{ String tableName = generateUniqueName(); createTableAndInsertValues(tableName, true); - Properties props= new Properties(); + Properties props= PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.LOG_LEVEL, loglevel.name()); Connection conn = DriverManager.getConnection(getUrl(),props); - assertEquals(conn.unwrap(PhoenixConnection.class).getLogLevel(),loglevel); + assertEquals(conn.unwrap(PhoenixMonitoredConnection.class).getLogLevel(),loglevel); final MyClock clock = new MyClock(100); EnvironmentEdgeManager.injectEdge(clock); try{ @@ -335,10 +345,10 @@ private void testPreparedStatement(LogLevel loglevel) throws Exception{ @Test public void testFailedQuery() throws Exception { String tableName = generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.LOG_LEVEL, LogLevel.DEBUG.name()); Connection conn = DriverManager.getConnection(getUrl(), props); - assertEquals(conn.unwrap(PhoenixConnection.class).getLogLevel(), LogLevel.DEBUG); + assertEquals(conn.unwrap(PhoenixMonitoredConnection.class).getLogLevel(), LogLevel.DEBUG); // Table does not exists String query = "SELECT * FROM " + tableName; @@ -374,7 +384,7 @@ public void testFailedQuery() throws Exception { private static void createTableAndInsertValues(String tableName, boolean resetGlobalMetricsAfterTableCreate) throws Exception { String ddl = "CREATE TABLE " + tableName + " (K VARCHAR NOT NULL PRIMARY KEY, V VARCHAR)"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); // executing 10 upserts/mutations. String dml = "UPSERT INTO " + tableName + " VALUES (?, ?)"; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java index 3f601e00b39..f4fdeb56969 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java @@ -17,12 +17,14 @@ */ package org.apache.phoenix.end2end; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.thirdparty.com.google.common.collect.Lists; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Pair; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.TestUtil; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -42,13 +44,13 @@ import java.util.Properties; import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB; +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.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; - @Category(ParallelStatsDisabledTest.class) public class QueryMoreIT extends ParallelStatsDisabledIT { @@ -105,7 +107,7 @@ private void testQueryMore(boolean queryAgainstTenantSpecificView, boolean dataT "VERSIONS = 1, MULTI_TENANT = true" + (dataTableSalted ? ", SALT_BUCKETS = 4" : ""); //create cursor and data tables. - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(cursorTableDDL); conn.createStatement().execute(baseDataTableDDL); conn.close(); @@ -141,7 +143,7 @@ private void testQueryMore(boolean queryAgainstTenantSpecificView, boolean dataT } */ - Connection conn2 = DriverManager.getConnection(getUrl()); + Connection conn2 = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn2.createStatement().executeQuery("SELECT count(*) from " + cursorTableName); rs.next(); assertEquals(numRowsPerTenant, rs.getInt(1)); @@ -178,7 +180,7 @@ private void testQueryMore(boolean queryAgainstTenantSpecificView, boolean dataT private Map> createHistoryTableRows(String dataTableName, String[] tenantIds, int numRowsPerTenant) throws Exception { String upsertDML = "UPSERT INTO " + dataTableName + " VALUES (?, ?, ?, ?, ?, ?, ?)"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Map> historyIdsForTenant = new HashMap>(); try { PreparedStatement stmt = conn.prepareStatement(upsertDML); @@ -209,7 +211,7 @@ private Map> createHistoryTableRows(String dataTableName, S private int upsertSelectRecordsInCursorTableForTenant(String tableOrViewName, boolean queryAgainstTenantView, String tenantId, String cursorQueryId, final String cursorTable) throws Exception { String sequenceName = "\"" + tenantId + "_SEQ\""; - Connection conn = queryAgainstTenantView ? getTenantSpecificConnection(tenantId) : DriverManager.getConnection(getUrl()); + Connection conn = queryAgainstTenantView ? getTenantSpecificConnection(tenantId) : DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); // Create a sequence. This sequence is used to fill cursor_order column for each row inserted in the cursor table. conn.createStatement().execute("CREATE SEQUENCE " + sequenceName + " CACHE " + Long.MAX_VALUE); @@ -244,7 +246,7 @@ private int upsertSelectRecordsInCursorTableForTenant(String tableOrViewName, bo } private Connection getTenantSpecificConnection(String tenantId) throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); return DriverManager.getConnection(getUrl(), props); } @@ -256,7 +258,7 @@ private String createTenantSpecificViewIfNecessary(String tenantViewName, Connec private String[] getRecordsOutofCursorTable(String tableOrViewName, boolean queryAgainstTenantSpecificView, String tenantId, String cursorQueryId, int startOrder, int endOrder, final String cursorTable) throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); List pkIds = new ArrayList(); String cols = queryAgainstTenantSpecificView ? "PARENT_ID, CREATED_DATE, ENTITY_HISTORY_ID" : "TENANT_ID, PARENT_ID, CREATED_DATE, ENTITY_HISTORY_ID"; String dynCols = queryAgainstTenantSpecificView ? "(PARENT_ID CHAR(15), CREATED_DATE DATE, ENTITY_HISTORY_ID CHAR(15))" : "(TENANT_ID CHAR(15), PARENT_ID CHAR(15), CREATED_DATE DATE, ENTITY_HISTORY_ID CHAR(15))"; @@ -289,7 +291,7 @@ private String[] getRecordsOutofCursorTable(String tableOrViewName, boolean quer } private List doQueryMore(boolean queryAgainstTenantView, String tenantId, String tenantViewName, String[] cursorIds) throws Exception { - Connection conn = queryAgainstTenantView ? getTenantSpecificConnection(tenantId) : DriverManager.getConnection(getUrl()); + Connection conn = queryAgainstTenantView ? getTenantSpecificConnection(tenantId) : DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = queryAgainstTenantView ? tenantViewName : dataTableName; @SuppressWarnings("unchecked") List> columns = queryAgainstTenantView ? Lists.newArrayList(new Pair(null, "PARENT_ID"), new Pair(null, "CREATED_DATE"), new Pair(null, "ENTITY_HISTORY_ID")) : Lists.newArrayList(new Pair(null, "TENANT_ID"), new Pair(null, "PARENT_ID"), new Pair(null, "CREATED_DATE"), new Pair(null, "ENTITY_HISTORY_ID")); @@ -341,7 +343,7 @@ public void testSelectColumnMoreThanOnce() throws Exception { Date date = new Date(System.currentTimeMillis()); initEntityHistoryTableValues("abcd", getDefaultSplits("abcd"), date, null); String query = "SELECT NEW_VALUE, NEW_VALUE FROM " + TestUtil.ENTITY_HISTORY_TABLE_NAME + " LIMIT 1"; - ResultSet rs = DriverManager.getConnection(getUrl()).createStatement().executeQuery(query); + ResultSet rs = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).createStatement().executeQuery(query); assertTrue(rs.next()); rs.getObject("NEW_VALUE"); assertFalse(rs.next()); @@ -351,7 +353,7 @@ public void testSelectColumnMoreThanOnce() throws Exception { @Test public void testNullBigDecimalWithScale() throws Exception { final String table = generateUniqueName(); - final Connection conn = DriverManager.getConnection(getUrl()); + final Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.setAutoCommit(true); try (Statement stmt = conn.createStatement()) { assertFalse(stmt.execute("CREATE TABLE IF NOT EXISTS " + table + " (\n" + @@ -379,7 +381,7 @@ public void testNullBigDecimalWithScale() throws Exception { @Test public void testRVCOnDescWithLeadingPKEquality() throws Exception { - final Connection conn = DriverManager.getConnection(getUrl()); + final Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String fullTableName = generateUniqueName(); try (Statement stmt = conn.createStatement()) { stmt.execute("CREATE TABLE " + fullTableName + "(\n" + @@ -433,7 +435,7 @@ public void testRVCOnDescWithLeadingPKEquality() throws Exception { @Test public void testSingleDescPKColumnComparison() throws Exception { - final Connection conn = DriverManager.getConnection(getUrl()); + final Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String fullTableName = generateUniqueName(); try (Statement stmt = conn.createStatement()) { stmt.execute("CREATE TABLE " + fullTableName + "(\n" + @@ -473,10 +475,10 @@ public void testSingleDescPKColumnComparison() throws Exception { @Test public void testMutationBatch() throws Exception { - Properties connectionProperties = new Properties(); + Properties connectionProperties = PropertiesUtil.deepCopy(TEST_PROPERTIES); connectionProperties.setProperty(QueryServices.MUTATE_BATCH_SIZE_ATTRIB, "10"); connectionProperties.setProperty(QueryServices.MUTATE_BATCH_SIZE_BYTES_ATTRIB, "128"); - PhoenixConnection connection = (PhoenixConnection) DriverManager.getConnection(getUrl(), connectionProperties); + PhoenixMonitoredConnection connection = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), connectionProperties); String fullTableName = generateUniqueName(); try (Statement stmt = connection.createStatement()) { stmt.execute("CREATE TABLE " + fullTableName + "(\n" + @@ -497,14 +499,14 @@ public void testMutationBatch() throws Exception { // set the batch size (rows) to 2 since three are at least 2 mutations when updates a single row connectionProperties.setProperty(QueryServices.MUTATE_BATCH_SIZE_ATTRIB, "2"); connectionProperties.setProperty(QueryServices.MUTATE_BATCH_SIZE_BYTES_ATTRIB, "128"); - connection = (PhoenixConnection) DriverManager.getConnection(getUrl(), connectionProperties); + connection = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), connectionProperties); upsertRows(connection, fullTableName); connection.commit(); // each row should be in its own batch assertEquals(2L, connection.getMutationState().getBatchCount()); } - private void upsertRows(PhoenixConnection conn, String fullTableName) throws SQLException { + private void upsertRows(PhoenixMonitoredConnection conn, String fullTableName) throws SQLException { PreparedStatement stmt = conn.prepareStatement("upsert into " + fullTableName + " (organization_id, entity_id, score) values (?,?,?)"); for (int i = 0; i < 4; i++) { @@ -516,7 +518,7 @@ private void upsertRows(PhoenixConnection conn, String fullTableName) throws SQL } @Test public void testRVCWithDescAndAscendingPK() throws Exception { - final Connection conn = DriverManager.getConnection(getUrl()); + final Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)); String fullTableName = generateUniqueName(); try (Statement stmt = conn.createStatement()) { stmt.execute("CREATE TABLE " + fullTableName + "(\n" @@ -554,7 +556,7 @@ public void testRVCOnTenantViewThroughGlobalIdxOrderByDesc() throws Exception { String tenantView = generateUniqueName(); String indexName = generateUniqueName(); // create base table and global view using global connection - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { Statement stmt = conn.createStatement(); stmt.execute( "CREATE TABLE " + fullTableName + "(\n" @@ -598,7 +600,7 @@ public void testRVCOnTenantViewThroughGlobalIdxOrderByDesc() throws Exception { } // create and use an tenant specific view to write data - try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1)) { + try (Connection viewConn = DriverManager.getConnection(TENANT_SPECIFIC_URL1,PropertiesUtil.deepCopy(TEST_PROPERTIES))) { Statement stmt = viewConn.createStatement(); stmt.execute("CREATE VIEW IF NOT EXISTS " + tenantView + " AS SELECT * FROM " + fullViewName); @@ -637,7 +639,7 @@ public void testRVCOnTenantViewThroughGlobalIdxOrderByDesc() throws Exception { } // validate that running query using global view gives same results - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { ResultSet rs = conn.createStatement().executeQuery("SELECT TEXT1, TEXT2 FROM " + fullViewName diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryTimeoutIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryTimeoutIT.java index 0ac5d50c100..df365b780ea 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryTimeoutIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryTimeoutIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -38,6 +39,7 @@ import org.apache.hadoop.hbase.regionserver.InternalScanner; import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixStatement; import org.apache.phoenix.query.BaseTest; import org.apache.phoenix.query.ConnectionQueryServices; @@ -54,7 +56,6 @@ import org.junit.experimental.categories.Category; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; - @Category(NeedsOwnMiniClusterTest.class) public class QueryTimeoutIT extends BaseTest { private String tableName; @@ -72,14 +73,17 @@ public static synchronized void doSetup() throws Exception { props.put(QueryServices.QUEUE_SIZE_ATTRIB, Integer.toString(10000)); props.put(QueryServices.EXPLAIN_CHUNK_COUNT_ATTRIB, Boolean.TRUE.toString()); props.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); - } + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @After public void assertNoUnfreedMemory() throws Exception { boolean refCountLeaked = isAnyStoreRefCountLeaked(); - try (Connection conn = DriverManager.getConnection(getUrl())) { - long unfreedBytes = conn.unwrap(PhoenixConnection.class).getQueryServices().clearCache(); + try (Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES))) { + long unfreedBytes = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().clearCache(); assertEquals(0, unfreedBytes); } assertFalse("refCount leaked", refCountLeaked); @@ -90,23 +94,23 @@ public void testSetRPCTimeOnConnection() throws Exception { Properties overriddenProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); overriddenProps.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS); overriddenProps.setProperty("hbase.rpc.timeout", Long.toString(100)); - String url = QueryUtil.getConnectionUrl(overriddenProps, config, "longRunning"); + String url = QueryUtil.getConnectionUrl(overriddenProps, getConfiguration(), "longRunning"); Connection conn1 = DriverManager.getConnection(url, overriddenProps); - ConnectionQueryServices s1 = conn1.unwrap(PhoenixConnection.class).getQueryServices(); + ConnectionQueryServices s1 = conn1.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); ReadOnlyProps configProps = s1.getProps(); assertEquals("100", configProps.get("hbase.rpc.timeout")); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS); Connection conn2 = DriverManager.getConnection(getUrl(), props); - ConnectionQueryServices s2 = conn2.unwrap(PhoenixConnection.class).getQueryServices(); + ConnectionQueryServices s2 = conn2.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); assertFalse(s1 == s2); Connection conn3 = DriverManager.getConnection(getUrl(), props); - ConnectionQueryServices s3 = conn3.unwrap(PhoenixConnection.class).getQueryServices(); + ConnectionQueryServices s3 = conn3.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); assertTrue(s2 == s3); Connection conn4 = DriverManager.getConnection(url, overriddenProps); - ConnectionQueryServices s4 = conn4.unwrap(PhoenixConnection.class).getQueryServices(); + ConnectionQueryServices s4 = conn4.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); assertTrue(s1 == s4); } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryWithLimitIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryWithLimitIT.java index 377b6d7cfc6..f64e63d7e67 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryWithLimitIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryWithLimitIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.query.QueryServicesOptions.UNLIMITED_QUEUE_SIZE; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; @@ -47,7 +48,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; - @Category(NeedsOwnMiniClusterTest.class) public class QueryWithLimitIT extends BaseTest { @@ -67,7 +67,11 @@ public static synchronized void doSetup() throws Exception { @Before public void setupDriver() throws Exception { destroyDriver(); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } tableName = generateUniqueName(); } @@ -134,7 +138,11 @@ public void testQueryWithoutLimitFails() throws Exception { // copy the existing properties Map newProps = Maps.newHashMap(props); newProps.put(QueryServices.QUEUE_SIZE_ATTRIB, Integer.toString(UNLIMITED_QUEUE_SIZE)); - setUpTestDriver(new ReadOnlyProps(newProps.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(newProps.entrySet().iterator()),new ReadOnlyProps(newProps.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(newProps.entrySet().iterator())); + } try (Connection conn = DriverManager.getConnection(getUrl(), connProps)) { // now the query should succeed ResultSet rs = conn.createStatement().executeQuery(query); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryWithOffsetIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryWithOffsetIT.java index bd258173005..c8062fe285f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryWithOffsetIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryWithOffsetIT.java @@ -45,7 +45,6 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; - @Category(ParallelStatsDisabledTest.class) @RunWith(Parameterized.class) public class QueryWithOffsetIT extends ParallelStatsDisabledIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryWithTableSampleIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryWithTableSampleIT.java index 673c3aabd7c..5e22ee00311 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryWithTableSampleIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryWithTableSampleIT.java @@ -38,7 +38,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsEnabledTest.class) public class QueryWithTableSampleIT extends ParallelStatsEnabledIT { private String tableName; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RTrimFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RTrimFunctionIT.java index dc075e7272f..765060efd12 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RTrimFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RTrimFunctionIT.java @@ -33,7 +33,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class RTrimFunctionIT extends ParallelStatsDisabledIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RangeScanIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RangeScanIT.java index e56b41bc137..367e720f461 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RangeScanIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RangeScanIT.java @@ -48,7 +48,6 @@ import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; - @Category(ParallelStatsDisabledTest.class) @RunWith(Parameterized.class) public class RangeScanIT extends BaseQueryIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReadIsolationLevelIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReadIsolationLevelIT.java index 84c88809ad4..e10ba1a20ff 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReadIsolationLevelIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReadIsolationLevelIT.java @@ -35,7 +35,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsEnabledTest.class) public class ReadIsolationLevelIT extends ParallelStatsEnabledIT { private static final String ENTITY_ID1= "000000000000001"; @@ -48,7 +47,7 @@ private static String initTableValues() throws Exception { String tableName = generateUniqueName(); ensureTableCreated(getUrl(),tableName, ATABLE_NAME); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection upsertConn = DriverManager.getConnection(getUrl(), props); // Insert all rows at ts PreparedStatement stmt = upsertConn.prepareStatement( @@ -71,7 +70,7 @@ private static String initTableValues() throws Exception { public void testStatementReadIsolationLevel() throws Exception { String tableName = initTableValues(); String query = "SELECT A_STRING FROM " + tableName + " WHERE ORGANIZATION_ID=? AND ENTITY_ID=?"; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); conn.setAutoCommit(true); Connection conn2 = DriverManager.getConnection(getUrl(), props); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReadOnlyIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReadOnlyIT.java index ffadb17f0e7..bb427fa83ed 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReadOnlyIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReadOnlyIT.java @@ -32,7 +32,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class ReadOnlyIT extends ParallelStatsDisabledIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReadOnlyViewOnReadOnlyIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReadOnlyViewOnReadOnlyIT.java index 4c2a82ed722..e41b0bbb9cd 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReadOnlyViewOnReadOnlyIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReadOnlyViewOnReadOnlyIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.UPDATE_CACHE_FREQUENCY; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import java.sql.Connection; @@ -25,24 +26,24 @@ import java.util.Properties; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.schema.PTable; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(NeedsOwnMiniClusterTest.class) public class ReadOnlyViewOnReadOnlyIT extends BaseTenantSpecificViewIndexIT { private static final long DEFAULT_TTL_FOR_TEST = 86400; private Connection getTenantConnection(final String tenantId) throws Exception { - Properties tenantProps = new Properties(); + Properties tenantProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); return DriverManager.getConnection(getUrl(), tenantProps); } @Test public void testReadOnlyTenantViewOnReadOnly() throws Exception { - - try(Connection connection = DriverManager.getConnection(getUrl())) { - PhoenixConnection conn = connection.unwrap(PhoenixConnection.class); + try(Connection connection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))){ + PhoenixMonitoredConnection conn = connection.unwrap(PhoenixMonitoredConnection.class); //base table String tableName = generateUniqueName(); conn.createStatement().execute("CREATE TABLE IF NOT EXISTS " + tableName + " (" @@ -66,7 +67,7 @@ public void testReadOnlyTenantViewOnReadOnly() throws Exception { //tenant child view String TENANT_ID = generateUniqueName(); - try (PhoenixConnection tenantConn = (PhoenixConnection) getTenantConnection(TENANT_ID)) + try (PhoenixMonitoredConnection tenantConn = (PhoenixMonitoredConnection) getTenantConnection(TENANT_ID)) { final Statement tenantStmt = tenantConn.createStatement(); tenantStmt.execute("CREATE VIEW " + "TENANT_VIEW_" + viewName + " AS SELECT * FROM " + viewName); @@ -80,8 +81,8 @@ public void testReadOnlyTenantViewOnReadOnly() throws Exception { @Test public void testReadOnlyViewOnReadOnly() throws Exception { - try(Connection connection = DriverManager.getConnection(getUrl())) { - PhoenixConnection conn = connection.unwrap(PhoenixConnection.class); + try(Connection connection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { + PhoenixMonitoredConnection conn = connection.unwrap(PhoenixMonitoredConnection.class); //base table String tableName = generateUniqueName(); conn.createStatement().execute("CREATE TABLE IF NOT EXISTS " + tableName + " (" diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RebuildIndexConnectionPropsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RebuildIndexConnectionPropsIT.java index a0b5ff1145a..6eb0256cdcb 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RebuildIndexConnectionPropsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RebuildIndexConnectionPropsIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -35,6 +36,7 @@ import org.apache.hadoop.hbase.client.Connection; import org.apache.phoenix.coprocessor.MetaDataRegionObserver; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixDriver; import org.apache.phoenix.jdbc.PhoenixEmbeddedDriver; import org.apache.phoenix.jdbc.PhoenixResultSet; @@ -50,7 +52,6 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(NeedsOwnMiniClusterTest.class) public class RebuildIndexConnectionPropsIT extends BaseTest { private static HBaseTestingUtility hbaseTestUtil; @@ -60,30 +61,41 @@ public class RebuildIndexConnectionPropsIT extends BaseTest { @BeforeClass public static synchronized void doSetup() throws Exception { - Configuration conf = HBaseConfiguration.create(); - hbaseTestUtil = new HBaseTestingUtility(conf); - Map serverProps = new HashMap<>(); - serverProps.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS); - // need at least one retry otherwise test fails - serverProps.put(QueryServices.INDEX_REBUILD_RPC_RETRIES_COUNTER, Long.toString(NUM_RPC_RETRIES)); - setUpConfigForMiniCluster(conf, new ReadOnlyProps(serverProps.entrySet().iterator())); - hbaseTestUtil.startMiniCluster(); - // establish url and quorum. Need to use PhoenixDriver and not PhoenixTestDriver - zkQuorum = "localhost:" + hbaseTestUtil.getZkCluster().getClientPort(); - url = PhoenixRuntime.JDBC_PROTOCOL_ZK + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum; + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + Map serverProps = new HashMap<>(); + serverProps.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS); + // need at least one retry otherwise test fails + serverProps.put(QueryServices.INDEX_REBUILD_RPC_RETRIES_COUNTER, Long.toString(NUM_RPC_RETRIES)); + setUpTestClusterForHA(new ReadOnlyProps(serverProps.entrySet().iterator()), ReadOnlyProps.EMPTY_PROPS); + hbaseTestUtil = getUtility(); + url = CLUSTERS.getJdbcHAUrlWithoutPrincipal(); + + } else { + Configuration conf = HBaseConfiguration.create(); + hbaseTestUtil = new HBaseTestingUtility(conf); + Map serverProps = new HashMap<>(); + serverProps.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS); + // need at least one retry otherwise test fails + serverProps.put(QueryServices.INDEX_REBUILD_RPC_RETRIES_COUNTER, Long.toString(NUM_RPC_RETRIES)); + setUpConfigForMiniCluster(conf, new ReadOnlyProps(serverProps.entrySet().iterator())); + hbaseTestUtil.startMiniCluster(); + // establish url and quorum. Need to use PhoenixDriver and not PhoenixTestDriver + zkQuorum = "localhost:" + hbaseTestUtil.getZkCluster().getClientPort(); + url = PhoenixRuntime.JDBC_PROTOCOL_ZK + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum; + DriverManager.registerDriver(PhoenixDriver.INSTANCE); + } Properties driverProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); - DriverManager.registerDriver(PhoenixDriver.INSTANCE); - try (PhoenixConnection phxConn = - DriverManager.getConnection(url, driverProps).unwrap(PhoenixConnection.class)) { + try (PhoenixMonitoredConnection phxConn = + DriverManager.getConnection(url, driverProps).unwrap(PhoenixMonitoredConnection.class)) { } } @Test public void testRebuildIndexConnectionProperties() throws Exception { - try (PhoenixConnection rebuildIndexConnection = + try (PhoenixMonitoredConnection rebuildIndexConnection = MetaDataRegionObserver.getRebuildIndexConnection(hbaseTestUtil.getMiniHBaseCluster().getConfiguration())) { - try (PhoenixConnection regularConnection = - DriverManager.getConnection(url).unwrap(PhoenixConnection.class)) { + try (PhoenixMonitoredConnection regularConnection = + DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixMonitoredConnection.class)) { String rebuildUrl = rebuildIndexConnection.getURL(); // assert that we are working with non-test urls assertFalse(PhoenixEmbeddedDriver.isTestUrl(url)); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexBulkLoadToolIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexBulkLoadToolIT.java index e96f97cd323..1adad0e395f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexBulkLoadToolIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexBulkLoadToolIT.java @@ -17,7 +17,9 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.query.QueryServices.DATE_FORMAT_ATTRIB; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -35,6 +37,7 @@ import org.apache.hadoop.fs.Path; import org.apache.phoenix.mapreduce.RegexBulkLoadTool; import org.apache.phoenix.util.DateUtil; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.PhoenixRuntime; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.TestUtil; @@ -42,7 +45,6 @@ import org.junit.Ignore; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(NeedsOwnMiniClusterTest.class) public class RegexBulkLoadToolIT extends BaseOwnClusterIT { @@ -51,9 +53,13 @@ public class RegexBulkLoadToolIT extends BaseOwnClusterIT { @BeforeClass public static synchronized void doSetup() throws Exception { - setUpTestDriver(ReadOnlyProps.EMPTY_PROPS); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(ReadOnlyProps.EMPTY_PROPS,ReadOnlyProps.EMPTY_PROPS); + } else { + setUpTestDriver(ReadOnlyProps.EMPTY_PROPS); + } zkQuorum = TestUtil.LOCALHOST + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + getUtility().getZkCluster().getClientPort(); - conn = DriverManager.getConnection(getUrl()); + conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); } @Test diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexpReplaceFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexpReplaceFunctionIT.java index d226a4a2f54..973a9942c84 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexpReplaceFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexpReplaceFunctionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.apache.phoenix.util.TestUtil.createGroupByTestTable; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -29,11 +30,11 @@ import java.sql.SQLException; import java.sql.Statement; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class RegexpReplaceFunctionIT extends ParallelStatsDisabledIT { @@ -43,7 +44,7 @@ public class RegexpReplaceFunctionIT extends ParallelStatsDisabledIT { @Before public void doBeforeTestSetup() throws Exception { this.tableName = generateUniqueName(); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); createGroupByTestTable(conn, tableName); insertRow(conn, "Report11", 10); insertRow(conn, "Report11", 10); @@ -65,7 +66,7 @@ private void insertRow(Connection conn, String uri, int appcpu) throws SQLExcept @Test public void testGroupByScanWithRegexpReplace() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("select REGEXP_REPLACE(uri, '[1-3]+', '*') suburi, sum(appcpu) sumcpu from " + this.tableName + " group by suburi"); assertTrue(rs.next()); @@ -85,7 +86,7 @@ public void testGroupByScanWithRegexpReplace() throws Exception { @Test public void testFilterWithRegexReplace() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery("select id from " + this.tableName + " where REGEXP_REPLACE(uri, '[2-3]+', '*') = 'Report*'"); assertTrue(rs.next()); assertEquals("id2", rs.getString(1)); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexpSplitFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexpSplitFunctionIT.java index b586395044e..78336c16186 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexpSplitFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexpSplitFunctionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -31,10 +32,10 @@ import java.sql.SQLException; import java.sql.Types; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class RegexpSplitFunctionIT extends ParallelStatsDisabledIT { @@ -71,7 +72,7 @@ private void initTable(Connection conn, String val, String separator) throws SQL @Test public void testSplit_ArrayReference() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); initTable(conn, "ONE,TWO,THREE"); ResultSet rs = conn.createStatement().executeQuery( @@ -83,8 +84,8 @@ public void testSplit_ArrayReference() throws SQLException { @Test public void testArrayLenWithRegExpSplit() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); - String val = "T"; + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + String val = "T"; for(int i = 1; i < Short.MAX_VALUE + 500; i++) { val += ",T"; } @@ -100,7 +101,7 @@ public void testArrayLenWithRegExpSplit() throws SQLException { @Test public void testSplit_InFilter() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); initTable(conn, "ONE,TWO,THREE"); ResultSet rs = conn.createStatement().executeQuery( @@ -112,7 +113,7 @@ public void testSplit_InFilter() throws SQLException { @Test public void testSplit_Upsert() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); initTable(conn, "ONE,TWO,THREE"); conn.createStatement().executeUpdate( @@ -129,7 +130,7 @@ public void testSplit_Upsert() throws SQLException { @Test public void testSplit_AlternateSeparator() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); initTable(conn, "ONE:TWO:THREE"); ResultSet rs = conn.createStatement().executeQuery( @@ -142,7 +143,7 @@ public void testSplit_AlternateSeparator() throws SQLException { @Test public void testSplit_DynamicPattern() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); initTable(conn, "ONE,TWO,THREE"); ResultSet rs = conn.createStatement().executeQuery( @@ -155,7 +156,7 @@ public void testSplit_DynamicPattern() throws SQLException { @Test public void testSplit_NoSplitString() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); initTable(conn, "CANNOT BE SPLIT"); ResultSet rs = conn.createStatement().executeQuery( @@ -168,7 +169,7 @@ public void testSplit_NoSplitString() throws SQLException { @Test public void testSplit_PatternBasedSplit() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); initTable(conn, "ONE!:TWO:::!THREE::!:FOUR"); ResultSet rs = conn.createStatement().executeQuery( @@ -181,7 +182,7 @@ public void testSplit_PatternBasedSplit() throws SQLException { @Test public void testSplit_PatternEscape() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); initTable(conn, "ONE|TWO|THREE"); ResultSet rs = conn.createStatement().executeQuery( @@ -194,7 +195,7 @@ public void testSplit_PatternEscape() throws SQLException { @Test public void testSplit_NullString() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); initTable(conn, null); ResultSet rs = conn.createStatement().executeQuery( @@ -206,7 +207,7 @@ public void testSplit_NullString() throws SQLException { @Test public void testSplit_NullSeparator() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); initTable(conn, "ONE,TWO,THREE"); ResultSet rs = conn.createStatement().executeQuery( @@ -218,7 +219,7 @@ public void testSplit_NullSeparator() throws SQLException { @Test public void testSplit_NullDynamicSeparator() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); initTable(conn, "ONE,TWO,THREE", null); ResultSet rs = conn.createStatement().executeQuery( diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexpSubstrFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexpSubstrFunctionIT.java index ba1d1eccba3..e1b0eb3c104 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexpSubstrFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RegexpSubstrFunctionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.apache.phoenix.util.TestUtil.createGroupByTestTable; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -29,11 +30,11 @@ import java.sql.SQLException; import java.sql.Statement; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class RegexpSubstrFunctionIT extends ParallelStatsDisabledIT { @@ -43,7 +44,7 @@ public class RegexpSubstrFunctionIT extends ParallelStatsDisabledIT { @Before public void doBeforeTestSetup() throws Exception { tableName = generateUniqueName(); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); createGroupByTestTable(conn, tableName); insertRow(conn, "Report1?1", 10); insertRow(conn, "Report1?2", 10); @@ -80,7 +81,7 @@ private void testGroupByScanWithRegexpSubstr(Connection conn, Integer offset, St @Test public void testGroupByScanWithRegexpSubstr() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); // Default offset testGroupByScanWithRegexpSubstr(conn, null, "Report"); // Positive offset @@ -102,7 +103,7 @@ private void testFilterWithRegexSubstr(Connection conn, Integer offset, String e @Test public void testFilterWithRegexSubstr() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); // Default offset testFilterWithRegexSubstr(conn, null, "Report"); // Positive offset diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RenewLeaseIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RenewLeaseIT.java index 938af05f98d..94a3aba54a9 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RenewLeaseIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RenewLeaseIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -43,7 +44,6 @@ import org.apache.phoenix.query.BaseTest; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; - @Category(NeedsOwnMiniClusterTest.class) public class RenewLeaseIT extends BaseTest { private static final long SCANNER_LEASE_TIMEOUT = 12000; @@ -57,13 +57,17 @@ public static synchronized void doSetup() throws Exception { Map clientProps = Maps.newHashMapWithExpectedSize(1); // Must update config before starting server serverProps.put(HConstants.HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD, Long.toString(SCANNER_LEASE_TIMEOUT)); - setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), new ReadOnlyProps(clientProps.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(serverProps.entrySet().iterator()), new ReadOnlyProps(clientProps.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), new ReadOnlyProps(clientProps.entrySet().iterator())); + } } @Test public void testLeaseDoesNotTimeout() throws Exception { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - Connection conn = DriverManager.getConnection(url, props); + Connection conn = DriverManager.getConnection(getUrl(), props); conn.createStatement().execute("create table " + TABLE_NAME + "(k VARCHAR PRIMARY KEY)"); SLEEP_NOW = true; try { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReverseFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReverseFunctionIT.java index 29dc58188c0..e7e9c86fc6f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReverseFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReverseFunctionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +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.assertNull; @@ -27,10 +28,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class ReverseFunctionIT extends ParallelStatsDisabledIT { @@ -67,7 +68,7 @@ private void testReverse(Connection conn, String s, String tableName) throws Exc @Test public void testSingleByteReverseAscending() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String s = "abc"; String tableName = initTable(conn, "ASC", s); testReverse(conn, s, tableName); @@ -75,7 +76,7 @@ public void testSingleByteReverseAscending() throws Exception { @Test public void testMultiByteReverseAscending() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String s = "ɚɦɰɸ"; String tableName = initTable(conn, "DESC", s); testReverse(conn, s, tableName); @@ -84,7 +85,7 @@ public void testMultiByteReverseAscending() throws Exception { @Test public void testSingleByteReverseDecending() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String s = "abc"; String tableName = initTable(conn, "DESC", s); testReverse(conn, s, tableName); @@ -92,7 +93,7 @@ public void testSingleByteReverseDecending() throws Exception { @Test public void testMultiByteReverseDecending() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String s = "ɚɦɰɸ"; String tableName = initTable(conn, "ASC", s); testReverse(conn, s, tableName); @@ -100,7 +101,7 @@ public void testMultiByteReverseDecending() throws Exception { @Test public void testNullReverse() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String s = "abc"; String tableName = initTable(conn, "ASC", s); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReverseScanIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReverseScanIT.java index 0f673c5250c..4d317472f48 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReverseScanIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ReverseScanIT.java @@ -45,7 +45,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class ReverseScanIT extends ParallelStatsDisabledIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RoundFloorCeilFuncIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RoundFloorCeilFuncIT.java index f7facaf2539..63e12508469 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RoundFloorCeilFuncIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RoundFloorCeilFuncIT.java @@ -72,7 +72,7 @@ public void initTable() throws Exception { Connection conn = null; PreparedStatement stmt = null; try { - conn = DriverManager.getConnection(getUrl()); + conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String ddl = "CREATE TABLE IF NOT EXISTS " + tableName + " (s VARCHAR NOT NULL PRIMARY KEY, dt DATE, t TIME, ts TIMESTAMP, \"DEC\" DECIMAL, doub DOUBLE, undoub UNSIGNED_DOUBLE, fl FLOAT, unfl UNSIGNED_FLOAT)"; conn.createStatement().execute(ddl); @@ -104,7 +104,7 @@ public void initTable() throws Exception { @Test public void testRoundingUpDate() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery("SELECT ROUND(dt, 'day'), ROUND(dt, 'hour', 1), ROUND(dt, 'minute', 1), ROUND(dt, 'second', 1), " + " ROUND(dt,'week'), ROUND(dt,'month') , ROUND(dt,'year') FROM " + tableName); assertTrue(rs.next()); @@ -126,7 +126,7 @@ public void testRoundingUpDate() throws Exception { @Test public void testRoundingUpDateInWhere() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM " + tableName + " WHERE ROUND(dt, 'day') = to_date('2012-01-02 00:00:00')"); assertTrue(rs.next()); @@ -134,7 +134,7 @@ public void testRoundingUpDateInWhere() throws Exception { @Test public void testFloorDate() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery("SELECT FLOOR(dt, 'day', 1), FLOOR(dt, 'hour', 1), FLOOR(dt, 'minute', 1), FLOOR(dt, 'second', 1)," + " FLOOR(dt,'week'), FLOOR(dt,'month'), FLOOR(dt,'year') FROM " + tableName); assertTrue(rs.next()); @@ -156,7 +156,7 @@ public void testFloorDate() throws Exception { @Test public void testFloorDateInWhere() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM " + tableName + " WHERE FLOOR(dt, 'hour') = to_date('2012-01-01 14:00:00')"); assertTrue(rs.next()); @@ -164,7 +164,7 @@ public void testFloorDateInWhere() throws Exception { @Test public void testCeilDate() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery("SELECT CEIL(dt, 'day', 1), CEIL(dt, 'hour', 1), CEIL(dt, 'minute', 1), CEIL(dt, 'second', 1), " + " CEIL(dt,'week') , CEIL(dt,'month') , CEIL(dt,'year') FROM " + tableName); assertTrue(rs.next()); @@ -187,7 +187,7 @@ public void testCeilDate() throws Exception { @Test public void testCeilDateInWhere() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM " + tableName + " WHERE CEIL(dt, 'second') = to_date('2012-01-01 14:25:29')"); assertTrue(rs.next()); @@ -195,7 +195,7 @@ public void testCeilDateInWhere() throws Exception { @Test public void testRoundingUpTimestamp() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery( "SELECT ROUND(ts, 'day'), ROUND(ts, 'hour', 1), ROUND(ts, 'minute', 1), ROUND(ts, 'second', 1), ROUND(ts, 'millisecond', 1) FROM " + tableName); @@ -218,7 +218,7 @@ public void testRoundingUpTimestamp() throws Exception { @Test public void testRoundingUpTimestampInWhere() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM " + tableName + " WHERE ROUND(ts, 'second') = to_date('2012-01-01 14:25:29')"); assertTrue(rs.next()); @@ -226,7 +226,7 @@ public void testRoundingUpTimestampInWhere() throws Exception { @Test public void testFloorTimestamp() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery("SELECT FLOOR(ts, 'day'), FLOOR(ts, 'hour', 1), FLOOR(ts, 'minute', 1), FLOOR(ts, 'second', 1), " + " FLOOR(ts, 'millisecond', 1) , FLOOR(ts,'week') , FLOOR(ts,'month') FROM " + tableName); @@ -252,7 +252,7 @@ public void testFloorTimestamp() throws Exception { @Test public void testFloorTimestampInWhere() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM " + tableName + " WHERE FLOOR(ts, 'second') = to_date('2012-01-01 14:25:28')"); assertTrue(rs.next()); @@ -260,7 +260,7 @@ public void testFloorTimestampInWhere() throws Exception { @Test public void testWeekFloorTimestampInWhere() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM " + tableName + " WHERE FLOOR(ts, 'week') = to_date('2011-12-26 00:00:00')"); assertTrue(rs.next()); @@ -268,7 +268,7 @@ public void testWeekFloorTimestampInWhere() throws Exception { @Test public void testCeilTimestamp() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery("SELECT CEIL(ts, 'day'), CEIL(ts, 'hour', 1), CEIL(ts, 'minute', 1), CEIL(ts, 'second', 1), CEIL(ts, 'millisecond', 1)," + " CEIL(ts,'week'), CEIL(ts,'month') , CEIL(ts,'year') FROM " + tableName); assertTrue(rs.next()); @@ -296,7 +296,7 @@ public void testCeilTimestamp() throws Exception { @Test public void testCeilTimestampInWhere() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM " + tableName + " WHERE CEIL(ts, 'second') = to_date('2012-01-01 14:25:29')"); assertTrue(rs.next()); @@ -304,7 +304,7 @@ public void testCeilTimestampInWhere() throws Exception { @Test public void testRoundingUpTime() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery("SELECT ROUND(t, 'day', 1), ROUND(t, 'hour', 1), ROUND(t, 'minute', 1), ROUND(t, 'second', 1)," + " ROUND(t,'week') , ROUND(t,'month') , ROUND(t,'year') FROM " + tableName); assertTrue(rs.next()); @@ -326,7 +326,7 @@ public void testRoundingUpTime() throws Exception { @Test public void testFloorTime() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery("SELECT FLOOR(t, 'day', 1), FLOOR(t, 'hour', 1), FLOOR(t, 'minute', 1), FLOOR(t, 'second', 1), " + " FLOOR(t, 'week'), FLOOR(t, 'month'), FLOOR(t, 'year') FROM " + tableName); assertTrue(rs.next()); @@ -348,7 +348,7 @@ public void testFloorTime() throws Exception { @Test public void testCeilTime() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery("SELECT CEIL(t, 'day', 1), CEIL(t, 'hour', 1), CEIL(t, 'minute', 1), CEIL(t, 'second', 1)," + " CEIL(t,'week') , CEIL(t,'month') , CEIL(t,'year') FROM " + tableName); assertTrue(rs.next()); @@ -370,7 +370,7 @@ public void testCeilTime() throws Exception { @Test public void testRoundingUpDecimal() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery( "SELECT ROUND(\"DEC\"), ROUND(\"DEC\", 1), ROUND(\"DEC\", 2), ROUND(\"DEC\", 3) FROM " + tableName); assertTrue(rs.next()); @@ -386,7 +386,7 @@ public void testRoundingUpDecimal() throws Exception { @Test public void testRoundingUpDecimalInWhere() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery( "SELECT * FROM " + tableName + " WHERE ROUND(\"DEC\", 2) = 1.26"); assertTrue(rs.next()); @@ -394,7 +394,7 @@ public void testRoundingUpDecimalInWhere() throws Exception { @Test public void testFloorDecimal() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery( "SELECT FLOOR(\"DEC\"), FLOOR(\"DEC\", 1), FLOOR(\"DEC\", 2), FLOOR(\"DEC\", 3) FROM " + tableName); assertTrue(rs.next()); @@ -410,7 +410,7 @@ public void testFloorDecimal() throws Exception { @Test public void testFloorDecimalInWhere() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery( "SELECT * FROM " + tableName + " WHERE FLOOR(\"DEC\", 2) = 1.26"); assertTrue(rs.next()); @@ -418,7 +418,7 @@ public void testFloorDecimalInWhere() throws Exception { @Test public void testCeilDecimal() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery( "SELECT CEIL(\"DEC\"), CEIL(\"DEC\", 1), CEIL(\"DEC\", 2), CEIL(\"DEC\", 3) FROM " + tableName); assertTrue(rs.next()); @@ -434,14 +434,14 @@ public void testCeilDecimal() throws Exception { @Test public void testCeilDecimalInWhere() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery( "SELECT * FROM " + tableName + " WHERE CEIL(\"DEC\", 2) = 1.27"); assertTrue(rs.next()); } @Test public void testRoundingUpDouble() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery( "SELECT ROUND(doub), ROUND(doub, 1), ROUND(doub, 2), ROUND(doub, 3) FROM " + tableName); assertTrue(rs.next()); @@ -453,7 +453,7 @@ public void testRoundingUpDouble() throws Exception { @Test public void testRoundingUpDoubleInWhere() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery( "SELECT * FROM " + tableName + " WHERE ROUND(\"DEC\", 2) = 1.26"); assertTrue(rs.next()); @@ -461,7 +461,7 @@ public void testRoundingUpDoubleInWhere() throws Exception { @Test public void testCeilDouble() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery( "SELECT CEIL(doub), CEIL(doub, 1), CEIL(doub, 2), CEIL(doub, 3) FROM " + tableName); assertTrue(rs.next()); @@ -473,7 +473,7 @@ public void testCeilDouble() throws Exception { @Test public void testCeilDoubleInWhere() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery( "SELECT * FROM " + tableName + " WHERE CEIL(doub, 2) = 1.27"); assertTrue(rs.next()); @@ -481,7 +481,7 @@ public void testCeilDoubleInWhere() throws Exception { @Test public void testFloorDouble() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery( "SELECT FLOOR(doub), FLOOR(doub, 1), FLOOR(doub, 2), FLOOR(doub, 3) FROM " + tableName); assertTrue(rs.next()); @@ -493,7 +493,7 @@ public void testFloorDouble() throws Exception { @Test public void testFloorDoubleInWhere() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery( "SELECT * FROM " + tableName + " WHERE FLOOR(doub, 2) = 1.26"); assertTrue(rs.next()); @@ -501,7 +501,7 @@ public void testFloorDoubleInWhere() throws Exception { @Test public void testRoundFloat() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery( "SELECT ROUND(fl), ROUND(fl, 1), ROUND(fl, 2), ROUND(fl, 3) FROM " + tableName); assertTrue(rs.next()); @@ -513,7 +513,7 @@ public void testRoundFloat() throws Exception { @Test public void testRoundUnsignedFloat() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery( "SELECT ROUND(unfl), ROUND(unfl, 1), ROUND(unfl, 2), ROUND(unfl, 3) FROM " + tableName); assertTrue(rs.next()); @@ -525,7 +525,7 @@ public void testRoundUnsignedFloat() throws Exception { @Test public void testRoundUnsignedDouble() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery( "SELECT ROUND(undoub), ROUND(undoub, 1), ROUND(undoub, 2), ROUND(undoub, 3) FROM " + tableName); @@ -539,8 +539,8 @@ public void testRoundUnsignedDouble() throws Exception { @Test public void testTimestampAggregateFunctions() throws Exception { String dateString = "2015-03-08 09:09:11.665"; - Properties props = new Properties(); - props.setProperty(QueryServices.DATE_FORMAT_TIMEZONE_ATTRIB, "GMT+1"); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); + props.setProperty(QueryServices.DATE_FORMAT_TIMEZONE_ATTRIB, "GMT+1"); Connection conn = DriverManager.getConnection(getUrl(), props); try { conn.prepareStatement( diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowKeyBytesStringFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowKeyBytesStringFunctionIT.java index 3f2167b062f..a90113e8750 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowKeyBytesStringFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowKeyBytesStringFunctionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -32,15 +33,15 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.query.QueryConstants; import org.apache.phoenix.schema.types.PInteger; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class RowKeyBytesStringFunctionIT extends ParallelStatsDisabledIT { @Test public void getRowKeyBytesAndVerify() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { int[] values = {3,7,9,158,5}; String tableName = generateUniqueName(); String ddl = @@ -65,7 +66,7 @@ public void getRowKeyBytesAndVerify() throws Exception { ResultSet rs = conn.createStatement().executeQuery("SELECT ROWKEY_BYTES_STRING() FROM " + tableName); try (org.apache.hadoop.hbase.client.Connection hconn = - ConnectionFactory.createConnection(config)) { + ConnectionFactory.createConnection(getConfiguration())) { Table table = hconn.getTable(TableName.valueOf(tableName)); int i = 0; while (rs.next()) { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowTimestampIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowTimestampIT.java index 4795f16c014..292255c29e7 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowTimestampIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowTimestampIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +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; @@ -45,12 +46,12 @@ import org.apache.phoenix.util.EncodedColumnsUtil; import org.apache.phoenix.util.EnvironmentEdgeManager; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; - @Category(ParallelStatsDisabledTest.class) @RunWith(Parameterized.class) public class RowTimestampIT extends ParallelStatsDisabledIT { @@ -89,13 +90,13 @@ public void testUpsertingRowTimestampColSpecifiedWithDate() throws Exception { private void upsertingRowTimestampColSpecified(String type) throws Exception { String tableName = generateUniqueName(); String indexName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement() .execute("CREATE TABLE IF NOT EXISTS " + tableName + " (PK1 VARCHAR NOT NULL, PK2 " + type + " NOT NULL, KV1 VARCHAR, KV2 VARCHAR CONSTRAINT PK PRIMARY KEY(PK1, PK2 " + sortOrder + " ROW_TIMESTAMP)) " + tableDDLOptions); } - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute("CREATE INDEX IF NOT EXISTS " + indexName + " ON " + tableName + " (PK2, KV1) INCLUDE (KV2)"); if (mutable) { @@ -113,9 +114,9 @@ private void upsertingRowTimestampColSpecified(String type) throws Exception { Thread.sleep(1000); long rowTimestamp = EnvironmentEdgeManager.currentTimeMillis(); Date rowTimestampDate = new Date(rowTimestamp); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); long scn = rowTimestamp-500; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), props)) { // The timestamp of the put will be the value of the row_timestamp column. PreparedStatement stmt = conn.prepareStatement( @@ -219,13 +220,13 @@ private void automaticallySettingRowTimestampForImmutableTableAndIndexes(String long startTime = EnvironmentEdgeManager.currentTimeMillis(); String tableName = generateUniqueName(); String indexName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement() .execute("CREATE TABLE IF NOT EXISTS " + tableName + " (PK1 VARCHAR NOT NULL, PK2 " + type + " NOT NULL, KV1 VARCHAR, KV2 VARCHAR CONSTRAINT PK PRIMARY KEY(PK1, PK2 " + sortOrder + " ROW_TIMESTAMP)) " + tableDDLOptions); } - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute("CREATE INDEX IF NOT EXISTS " + indexName + " ON " + tableName + " (PK2, KV1) INCLUDE (KV2)"); if (mutable) { @@ -240,7 +241,7 @@ private void automaticallySettingRowTimestampForImmutableTableAndIndexes(String throw e; } } - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { // Upsert values where row_timestamp column PK2 is not set and the column names are // specified // This should upsert data with the value for PK2 as the s @@ -254,7 +255,7 @@ private void automaticallySettingRowTimestampForImmutableTableAndIndexes(String conn.commit(); } long endTime = EnvironmentEdgeManager.currentTimeMillis(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { // Now query for data that was upserted above. If the row key was generated correctly // then we should be able to see // the data in this query. @@ -312,13 +313,13 @@ private void automaticallySettingRowTimestampForImmutableTableAndIndexes(String @Test public void testComparisonOperatorsOnRowTimestampCol() throws Exception { String tableName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement() .execute("CREATE TABLE IF NOT EXISTS " + tableName + " (PK1 VARCHAR NOT NULL, PK2 DATE NOT NULL, KV1 VARCHAR CONSTRAINT PK PRIMARY KEY(PK1, PK2 " + sortOrder + " ROW_TIMESTAMP)) " + tableDDLOptions); } - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String upsert = "UPSERT INTO " + tableName + " VALUES (?, ?, ?)"; PreparedStatement stmt = conn.prepareStatement(upsert); stmt.setString(1, "a"); @@ -339,7 +340,7 @@ public void testComparisonOperatorsOnRowTimestampCol() throws Exception { stmt.executeUpdate(); conn.commit(); } - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { assertNumRecords(3, "SELECT count(*) from " + tableName + " WHERE PK2 > ?", conn, new Date(10)); assertNumRecords(1, "SELECT count(*) from " + tableName + " WHERE PK2 < ? AND PK2 > ?", @@ -372,12 +373,12 @@ private void assertNumRecords(int count, String sql, Connection conn, Date... pa @Test public void testDisallowNegativeValuesForRowTsColumn() throws Exception { String tableName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement() .execute("CREATE TABLE " + tableName + " (PK1 DATE NOT NULL PRIMARY KEY " + sortOrder + " ROW_TIMESTAMP, KV1 VARCHAR) " + tableDDLOptions); } - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { Date d = new Date(-100); PreparedStatement stmt = conn.prepareStatement( diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java index f40ca609494..737dca1100c 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java @@ -68,7 +68,6 @@ import org.apache.phoenix.thirdparty.com.google.common.base.Joiner; import org.apache.phoenix.thirdparty.com.google.common.collect.Lists; import org.apache.phoenix.util.TestUtil; - @Category(ParallelStatsDisabledTest.class) public class RowValueConstructorIT extends ParallelStatsDisabledIT { @@ -1866,7 +1865,7 @@ public void testMultiTenantRVC() throws Exception { */ public void testRVCWithAndClause() throws Exception { final int numItemsInClause = 5; - Properties tenantProps = new Properties(); + Properties tenantProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, "tenant1"); String fullTableName = SchemaUtil.getTableName("S", "T_" + generateUniqueName()); String fullViewName = SchemaUtil.getTableName("S", "V_" + generateUniqueName()); @@ -1903,7 +1902,7 @@ public void testRVCWithAndClause() throws Exception { public void testTrailingSeparator() throws Exception { Connection conn = null; try { - conn = DriverManager.getConnection(getUrl()); + conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute("CREATE TABLE test2961 (\n" + "ACCOUNT_ID VARCHAR NOT NULL,\n" + "BUCKET_ID VARCHAR NOT NULL,\n" + "OBJECT_ID VARCHAR NOT NULL,\n" + "OBJECT_VERSION VARCHAR NOT NULL,\n" @@ -1932,7 +1931,7 @@ public void testTrailingSeparator() throws Exception { @Test public void testRVCConjunction() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())){ + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tableName = generateUniqueName(); String ddl = String.format("create table %s(a varchar(10) not null, b varchar(10) not null, c varchar(10) not null constraint pk primary key(a, b, c))",tableName); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorOffsetIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorOffsetIT.java index 8ee6de18bca..e31e5d8226b 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorOffsetIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorOffsetIT.java @@ -47,7 +47,6 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class RowValueConstructorOffsetIT extends ParallelStatsDisabledIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorOffsetOptionalIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorOffsetOptionalIT.java index f46bdea9088..1207062f423 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorOffsetOptionalIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorOffsetOptionalIT.java @@ -222,7 +222,7 @@ private void createMultiTenantBaseTable(String baseTableName) throws SQLExceptio } private Connection getTenantConnection(String tenantId) throws SQLException { - Properties tenantProps = new Properties(); + Properties tenantProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); return DriverManager.getConnection(getUrl(), tenantProps); } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SCNIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SCNIT.java index d0a83d1d76a..1d2bb20eea4 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SCNIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SCNIT.java @@ -29,10 +29,11 @@ import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import org.apache.phoenix.util.SchemaUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class SCNIT extends ParallelStatsDisabledIT { @@ -43,7 +44,7 @@ public void testReadBeforeDelete() throws Exception { String fullTableName = SchemaUtil.getTableName(schemaName, tableName); long timeBeforeDelete; long timeAfterDelete; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute("CREATE TABLE " + fullTableName + "(k VARCHAR PRIMARY KEY, v VARCHAR)"); conn.createStatement().execute("UPSERT INTO " + fullTableName + " VALUES('a','aa')"); conn.createStatement().execute("UPSERT INTO " + fullTableName + " VALUES('b','bb')"); @@ -56,7 +57,7 @@ public void testReadBeforeDelete() throws Exception { timeAfterDelete = EnvironmentEdgeManager.currentTime() + 1; } - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(timeBeforeDelete)); try (Connection connscn = DriverManager.getConnection(getUrl(), props)) { ResultSet rs = connscn.createStatement().executeQuery("select * from " + fullTableName); @@ -70,6 +71,7 @@ public void testReadBeforeDelete() throws Exception { rs.close(); } props.clear(); + props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(timeAfterDelete)); try (Connection connscn = DriverManager.getConnection(getUrl(), props)) { ResultSet rs = connscn.createStatement().executeQuery("select * from " + fullTableName); @@ -89,7 +91,7 @@ public void testSCNWithTTL() throws Exception { String fullTableName = createTableWithTTL(ttl); //sleep for one second longer than ttl Thread.sleep(ttl * 1000 + 1000); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(EnvironmentEdgeManager.currentTime() - 1000)); try (Connection connscn = DriverManager.getConnection(getUrl(), props)) { @@ -109,7 +111,7 @@ private String createTableWithTTL(int ttl) throws SQLException, InterruptedExcep } String ddlOptions = optionsBuilder.toString(); String fullTableName = SchemaUtil.getTableName(schemaName, tableName); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement() .execute(String.format("CREATE TABLE %s" + "(k VARCHAR PRIMARY KEY, f.v VARCHAR) %s", fullTableName, ddlOptions)); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ScanUncommittedWithRegionMovesIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ScanUncommittedWithRegionMovesIT.java index cf4e69b4290..f1db3fce82d 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ScanUncommittedWithRegionMovesIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ScanUncommittedWithRegionMovesIT.java @@ -26,6 +26,7 @@ import org.apache.phoenix.iterate.ScanningResultPostDummyResultCaller; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.junit.After; import org.junit.BeforeClass; @@ -45,6 +46,8 @@ import java.util.Map; import java.util.Set; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +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; @@ -95,7 +98,11 @@ public static synchronized void doSetup() throws Exception { props.put(HConstants.HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY, String.valueOf(1)); props.put(QueryServices.PHOENIX_POST_DUMMY_PROCESS, TestScanningResultPostDummyResultCaller.class.getName()); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @After @@ -152,7 +159,7 @@ public void testUncoveredIndex() throws Exception { hasTestStarted = true; String dataTableName = generateUniqueName(); populateTable(dataTableName); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String indexTableName = generateUniqueName(); conn.createStatement().execute("CREATE UNCOVERED INDEX " + indexTableName + " on " + dataTableName + " (val1) "); @@ -172,7 +179,7 @@ public void testUncoveredIndex() throws Exception { assertEquals("abcd", rs.getString(2)); moveRegionsOfTable(dataTableName); moveRegionsOfTable(indexTableName); - try (Connection newConn = DriverManager.getConnection(getUrl())) { + try (Connection newConn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { newConn.createStatement().execute("upsert into " + dataTableName + " (id, val1, val2, val3) values ('c1', 'cd1','cde1', 'cdef1')"); newConn.createStatement().execute("upsert into " + dataTableName @@ -197,7 +204,7 @@ public void testCoveredIndex() throws Exception { hasTestStarted = true; String dataTableName = generateUniqueName(); populateTable(dataTableName); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String indexTableName = generateUniqueName(); conn.createStatement().execute("CREATE INDEX " + indexTableName + " on " + dataTableName + " (val1) INCLUDE (val2, val3)"); @@ -217,7 +224,7 @@ public void testCoveredIndex() throws Exception { assertEquals("abcd", rs.getString(2)); moveRegionsOfTable(dataTableName); moveRegionsOfTable(indexTableName); - try (Connection newConn = DriverManager.getConnection(getUrl())) { + try (Connection newConn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { newConn.createStatement().execute("upsert into " + dataTableName + " (id, val1, val2, val3) values ('c1', 'cd1','cde1', 'cdef1')"); newConn.createStatement().execute("upsert into " + dataTableName @@ -242,7 +249,7 @@ public void testNoIndex() throws Exception { hasTestStarted = true; String dataTableName = generateUniqueName(); populateTable(dataTableName); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { populateTableWithAdditionalRows(dataTableName, conn); conn.commit(); TABLE_NAMES.add(dataTableName); @@ -257,7 +264,7 @@ public void testNoIndex() throws Exception { assertEquals("abc", rs.getString(1)); assertEquals("abcd", rs.getString(2)); moveRegionsOfTable(dataTableName); - try (Connection newConn = DriverManager.getConnection(getUrl())) { + try (Connection newConn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { newConn.createStatement().execute("upsert into " + dataTableName + " (id, val1, val2, val3) values ('c1', 'cd1','cde1', 'cdef1')"); newConn.createStatement().execute("upsert into " + dataTableName @@ -282,7 +289,7 @@ public void testUncoveredIndex2() throws Exception { hasTestStarted = true; String dataTableName = generateUniqueName(); populateTable(dataTableName); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String indexTableName = generateUniqueName(); conn.createStatement().execute("CREATE UNCOVERED INDEX " + indexTableName + " on " + dataTableName + " (val1) "); @@ -298,7 +305,7 @@ public void testUncoveredIndex2() throws Exception { assertTrue(rs.next()); assertEquals("abc", rs.getString(1)); assertEquals("abcd", rs.getString(2)); - try (Connection newConn = DriverManager.getConnection(getUrl())) { + try (Connection newConn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { newConn.createStatement().execute("upsert into " + dataTableName + " (id, val1, val2, val3) values ('c1', 'cd1','cde1', 'cdef1')"); newConn.createStatement().execute("upsert into " + dataTableName @@ -323,7 +330,7 @@ public void testCoveredIndex2() throws Exception { hasTestStarted = true; String dataTableName = generateUniqueName(); populateTable(dataTableName); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String indexTableName = generateUniqueName(); conn.createStatement().execute("CREATE INDEX " + indexTableName + " on " + dataTableName + " (val1) INCLUDE (val2, val3)"); @@ -339,7 +346,7 @@ public void testCoveredIndex2() throws Exception { assertTrue(rs.next()); assertEquals("abc", rs.getString(1)); assertEquals("abcd", rs.getString(2)); - try (Connection newConn = DriverManager.getConnection(getUrl())) { + try (Connection newConn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { newConn.createStatement().execute("upsert into " + dataTableName + " (id, val1, val2, val3) values ('c1', 'cd1','cde1', 'cdef1')"); newConn.createStatement().execute("upsert into " + dataTableName @@ -364,7 +371,7 @@ public void testNoIndex2() throws Exception { hasTestStarted = true; String dataTableName = generateUniqueName(); populateTable(dataTableName); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { populateTableWithAdditionalRows(dataTableName, conn); conn.commit(); TABLE_NAMES.add(dataTableName); @@ -378,7 +385,7 @@ public void testNoIndex2() throws Exception { assertTrue(rs.next()); assertEquals("abc", rs.getString(1)); assertEquals("abcd", rs.getString(2)); - try (Connection newConn = DriverManager.getConnection(getUrl())) { + try (Connection newConn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { newConn.createStatement().execute("upsert into " + dataTableName + " (id, val1, val2, val3) values ('c1', 'cd1','cde1', 'cdef1')"); newConn.createStatement().execute("upsert into " + dataTableName @@ -536,7 +543,7 @@ private static void assertRowsWithOldScanner(String dataTableName, String indexT } private void populateTable(String tableName) throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute("create table " + tableName + " (id varchar(10) not null primary key, val1 varchar(10), val2 varchar(10)," + " val3 varchar(10)) SPLIT ON ('d', 'h', 'k')"); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SchemaRegistryFailureIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SchemaRegistryFailureIT.java index 3273ae66262..d57784b5f8b 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SchemaRegistryFailureIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SchemaRegistryFailureIT.java @@ -21,14 +21,19 @@ import org.apache.hadoop.conf.Configuration; import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.schema.PTable; import org.apache.phoenix.schema.TableNotFoundException; import org.apache.phoenix.schema.export.SchemaRegistryRepository; import org.apache.phoenix.schema.export.SchemaWriter; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; + +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -41,7 +46,6 @@ import java.util.Map; import static org.apache.phoenix.coprocessorclient.BaseScannerRegionObserverConstants.PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY; - @Category(NeedsOwnMiniClusterTest.class) public class SchemaRegistryFailureIT extends ParallelStatsDisabledIT{ @@ -51,7 +55,11 @@ public static synchronized void doSetup() throws Exception { props.put(PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY, Integer.toString(60*60)); // An hour props.put(SchemaRegistryRepository.SCHEMA_REGISTRY_IMPL_KEY, ExplodingSchemaRegistryRepository.class.getName()); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @Test @@ -59,7 +67,7 @@ public void testFailedCreateRollback() throws Exception { String schemaName = "S_" + generateUniqueName(); String tableName = "T_" + generateUniqueName(); String fullTableName = SchemaUtil.getTableName(schemaName, tableName); - try (PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl())) { + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String ddl = "CREATE TABLE " + fullTableName + " (id char(1) NOT NULL," + " col1 integer NOT NULL," + " col2 bigint NOT NULL," + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1, col2)) " @@ -75,8 +83,15 @@ public void testFailedCreateRollback() throws Exception { try { PTable table = conn.getTable(fullTableName); Assert.fail("Shouldn't have found the table because it shouldn't have been created"); - } catch (TableNotFoundException tnfe) { - //eat the exception, which is what we expect + } catch (Exception e) { + if (e instanceof SQLException) { + if (e.getCause() instanceof TableNotFoundException) { + //Expected in case of HA Enabled + //eat the exception, which is what we expect + } + } else if (e instanceof TableNotFoundException) { + //eat the exception, which is what we expect + } } } } @@ -86,7 +101,7 @@ public void testFailedAlterRollback() throws Exception { String schemaName = "S_" + generateUniqueName(); String tableName = "T_" + generateUniqueName(); String fullTableName = SchemaUtil.getTableName(schemaName, tableName); - try (PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl())) { + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String ddl = "CREATE TABLE " + fullTableName + " (id char(1) NOT NULL," + " col1 integer NOT NULL," + " col2 bigint NOT NULL," + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1, col2)) " + "MULTI_TENANT=true"; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequenceIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequenceIT.java index 9dc82258ca2..0a5a682c011 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequenceIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequenceIT.java @@ -42,6 +42,7 @@ import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixPreparedStatement; import org.apache.phoenix.jdbc.PhoenixStatement; import org.apache.phoenix.query.QueryServices; @@ -62,7 +63,6 @@ import org.junit.experimental.categories.Category; import org.apache.phoenix.thirdparty.com.google.common.collect.Lists; - @Category(ParallelStatsDisabledTest.class) public class SequenceIT extends ParallelStatsDisabledIT { private static final String SELECT_NEXT_VALUE_SQL = "SELECT NEXT VALUE FOR %s"; @@ -239,7 +239,7 @@ public void testCreateSequence() throws Exception { String schemaName = getSchemaName(sequenceName); conn.createStatement().execute("CREATE SEQUENCE " + sequenceName + " START WITH 2 INCREMENT BY 4"); - int bucketNum = conn.unwrap(PhoenixConnection.class) + int bucketNum = conn.unwrap(PhoenixMonitoredConnection.class) .getTableNoCache(SYSTEM_CATALOG_SCHEMA + "." + TYPE_SEQUENCE).getBucketNum(); assertEquals("Salt bucket for SYSTEM.SEQUENCE should be test default", bucketNum, QueryServicesTestImpl.DEFAULT_SEQUENCE_TABLE_SALT_BUCKETS); String query = "SELECT sequence_schema, sequence_name, current_value, increment_by FROM \"SYSTEM\".\"SEQUENCE\" WHERE sequence_name='" + sequenceNameWithoutSchema + "'"; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequencePointInTimeIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequencePointInTimeIT.java index 7159d196b2d..39645bd249f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequencePointInTimeIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SequencePointInTimeIT.java @@ -18,6 +18,7 @@ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -42,7 +43,6 @@ import org.junit.experimental.categories.Category; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; - @Category(NeedsOwnMiniClusterTest.class) public class SequencePointInTimeIT extends BaseTest { private static final String SCHEMA_NAME = "S"; @@ -56,7 +56,11 @@ public static synchronized void doSetup() throws Exception { // Must update config before starting server props.put(QueryServices.DEFAULT_SYSTEM_KEEP_DELETED_CELLS_ATTRIB, Boolean.TRUE.toString()); props.put(QueryServices.DEFAULT_SYSTEM_MAX_VERSIONS_ATTRIB, "5"); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()), new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @Test diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SerialIteratorsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SerialIteratorsIT.java index 5bdef0ae5d1..503b54f0db4 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SerialIteratorsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SerialIteratorsIT.java @@ -32,7 +32,6 @@ import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class SerialIteratorsIT extends ParallelStatsDisabledIT { private String tableName = generateUniqueName(); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ServerExceptionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ServerExceptionIT.java index 3f57522da21..ec71598c13f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ServerExceptionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ServerExceptionIT.java @@ -32,7 +32,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class ServerExceptionIT extends ParallelStatsDisabledIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ServerPagingIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ServerPagingIT.java index f9fb3fc9e4a..edf1b2d3bd8 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ServerPagingIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ServerPagingIT.java @@ -19,6 +19,7 @@ import static org.apache.phoenix.end2end.index.GlobalIndexCheckerIT.assertExplainPlan; import static org.apache.phoenix.end2end.index.GlobalIndexCheckerIT.assertExplainPlanWithLimit; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_PAGED_ROWS_COUNTER; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; @@ -52,7 +53,6 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(NeedsOwnMiniClusterTest.class) public class ServerPagingIT extends ParallelStatsDisabledIT { @@ -61,8 +61,11 @@ public static synchronized void doSetup() throws Exception { Map props = Maps.newHashMapWithExpectedSize(2); props.put(QueryServices.PHOENIX_SERVER_PAGE_SIZE_MS, Long.toString(0)); props.put(QueryServices.COLLECT_REQUEST_LEVEL_METRICS, String.valueOf(true)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); - } + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } private void assertServerPagingMetric(String tableName, ResultSet rs, boolean isPaged) throws SQLException { Map> metrics = PhoenixRuntime.getRequestReadMetricInfo(rs); @@ -374,7 +377,7 @@ public void testGroupBy() throws SQLException { public void testUncoveredQuery() throws Exception { String dataTableName = generateUniqueName(); populateTable(dataTableName); // with two rows ('a', 'ab', 'abc', 'abcd') and ('b', 'bc', 'bcd', 'bcde') - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String indexTableName = generateUniqueName(); conn.createStatement().execute("CREATE UNCOVERED INDEX " + indexTableName + " on " + dataTableName + " (val1) "); @@ -431,7 +434,7 @@ public void testUncoveredQuery() throws Exception { @Test public void testNumberOfRPCsWithPaging() throws SQLException { // insert 200 rows - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); PhoenixStatement stmt = conn.createStatement().unwrap(PhoenixStatement.class); stmt.execute("CREATE TABLE " + tableName @@ -457,7 +460,7 @@ public void testNumberOfRPCsWithPaging() throws SQLException { } private void populateTable(String tableName) throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute("create table " + tableName + " (id varchar(10) not null primary key, val1 varchar(10), val2 varchar(10)," + " val3 varchar(10))"); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ServerPagingWithRegionMovesIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ServerPagingWithRegionMovesIT.java index 76aea5b6816..b218a8f1726 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ServerPagingWithRegionMovesIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ServerPagingWithRegionMovesIT.java @@ -56,6 +56,7 @@ import java.util.Map; import java.util.Properties; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_PAGED_ROWS_COUNTER; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; @@ -130,7 +131,11 @@ public static synchronized void doSetup() throws Exception { TestScanningResultPostDummyResultCaller.class.getName()); props.put(QueryServices.PHOENIX_POST_VALID_PROCESS, TestScanningResultPostValidResultCaller.class.getName()); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @After diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SetPropertyIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SetPropertyIT.java index 78e9bf7ac1d..1f8508b75f5 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SetPropertyIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SetPropertyIT.java @@ -18,6 +18,7 @@ package org.apache.phoenix.end2end; import static org.apache.phoenix.coprocessorclient.BaseScannerRegionObserverConstants.PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.schema.LiteralTTLExpression.TTL_EXPRESSION_NOT_DEFINED; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; @@ -41,6 +42,7 @@ import org.apache.hadoop.hbase.client.TableDescriptorBuilder; import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.PTable; import org.apache.phoenix.schema.PTableKey; @@ -56,7 +58,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; - @RunWith(Parameterized.class) public abstract class SetPropertyIT extends ParallelStatsDisabledIT { @@ -72,7 +73,11 @@ public static synchronized void doSetup() throws Exception { Map props = Maps.newHashMapWithExpectedSize(1); props.put(PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY, Integer.toString(60*60)); // An hour props.put(QueryServices.USE_STATS_FOR_PARALLELIZATION, Boolean.toString(false)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } public SetPropertyIT(boolean columnEncoded) { @@ -115,7 +120,7 @@ public void testSetHColumnProperties() throws Exception { conn1.createStatement().execute(ddl); ddl = "ALTER TABLE " + dataTableFullName + " SET REPLICATION_SCOPE=1"; conn1.createStatement().execute(ddl); - try (Admin admin = conn1.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn1.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { ColumnFamilyDescriptor[] columnFamilies = admin.getDescriptor(TableName.valueOf(dataTableFullName)) .getColumnFamilies(); assertEquals(1, columnFamilies.length); @@ -138,7 +143,7 @@ public void testSetHTableProperties() throws Exception { conn1.createStatement().execute(ddl); ddl = "ALTER TABLE " + dataTableFullName + " SET COMPACTION_ENABLED=FALSE"; conn1.createStatement().execute(ddl); - try (Admin admin = conn1.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn1.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { TableDescriptor tableDesc = admin.getDescriptor(TableName.valueOf(dataTableFullName)); assertEquals(1, tableDesc.getColumnFamilies().length); assertEquals("0", tableDesc.getColumnFamilies()[0].getNameAsString()); @@ -160,7 +165,7 @@ public void testSetHTableAndHColumnProperties() throws Exception { conn1.createStatement().execute(ddl); ddl = "ALTER TABLE " + dataTableFullName + " SET COMPACTION_ENABLED = FALSE, REPLICATION_SCOPE = 1"; conn1.createStatement().execute(ddl); - try (Admin admin = conn1.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn1.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { TableDescriptor tableDesc = admin.getDescriptor(TableName.valueOf(dataTableFullName)); ColumnFamilyDescriptor[] columnFamilies = tableDesc.getColumnFamilies(); assertEquals(1, columnFamilies.length); @@ -190,7 +195,7 @@ public void testSetHTableHColumnAndPhoenixTableProperties() throws Exception { "MIN_VERSIONS = 8, CF1.BLOCKSIZE = 50000, KEEP_DELETED_CELLS = false"; conn.createStatement().execute(ddl); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { TableDescriptor tableDesc = admin.getDescriptor(TableName.valueOf(dataTableFullName)); ColumnFamilyDescriptor[] columnFamilies = tableDesc.getColumnFamilies(); assertEquals(3, columnFamilies.length); @@ -370,12 +375,12 @@ public void testSetForSomePhoenixTablePropertiesOnViewsAllowed() throws Exceptio ddl = "ALTER VIEW " + viewFullName + " SET UPDATE_CACHE_FREQUENCY = 10"; conn1.createStatement().execute(ddl); conn1.createStatement().execute("SELECT * FROM " + viewFullName); - PhoenixConnection pconn = conn1.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pconn = conn1.unwrap(PhoenixMonitoredConnection.class); assertEquals(10, pconn.getTable(new PTableKey(pconn.getTenantId(), viewFullName)).getUpdateCacheFrequency()); ddl = "ALTER VIEW " + viewFullName + " SET UPDATE_CACHE_FREQUENCY = 20"; conn1.createStatement().execute(ddl); conn1.createStatement().execute("SELECT * FROM " + viewFullName); - pconn = conn1.unwrap(PhoenixConnection.class); + pconn = conn1.unwrap(PhoenixMonitoredConnection.class); assertEquals(20, pconn.getTable(new PTableKey(pconn.getTenantId(), viewFullName)).getUpdateCacheFrequency()); assertImmutableRows(conn1, viewFullName, false); ddl = "ALTER VIEW " + viewFullName + " SET DISABLE_WAL = TRUE"; @@ -412,7 +417,7 @@ public void testSettingPropertiesWhenTableHasDefaultColFamilySpecified() throws + " SET COMPACTION_ENABLED = FALSE, CF.BLOCKSIZE=50000, IMMUTABLE_ROWS = TRUE, TTL=1000"; conn.createStatement().execute(ddl); assertImmutableRows(conn, dataTableFullName, true); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { TableDescriptor tableDesc = admin.getDescriptor(TableName.valueOf(dataTableFullName)); ColumnFamilyDescriptor[] columnFamilies = tableDesc.getColumnFamilies(); assertEquals(2, columnFamilies.length); @@ -432,7 +437,7 @@ public void testSettingPropertiesWhenTableHasDefaultColFamilySpecified() throws } private static void assertImmutableRows(Connection conn, String fullTableName, boolean expectedValue) throws SQLException { - PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pconn = conn.unwrap(PhoenixMonitoredConnection.class); assertEquals(expectedValue, pconn.getTable(new PTableKey(pconn.getTenantId(), fullTableName)).isImmutableRows()); } @@ -448,7 +453,7 @@ public void testSetPropertyAndAddColumnForExistingColumnFamily() throws Exceptio conn.createStatement().execute(ddl); conn.createStatement().execute( "ALTER TABLE " + dataTableFullName + " ADD CF.col3 integer CF.IN_MEMORY=true"); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { ColumnFamilyDescriptor[] columnFamilies = admin.getDescriptor(TableName.valueOf(dataTableFullName)) .getColumnFamilies(); assertEquals(2, columnFamilies.length); @@ -477,7 +482,7 @@ public void testSetPropertyAndAddColumnForNewAndExistingColumnFamily() throws Ex "ALTER TABLE " + dataTableFullName + " ADD col4 integer, CF1.col5 integer, CF2.col6 integer IN_MEMORY=true, REPLICATION_SCOPE=1, CF2.IN_MEMORY=false "); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { ColumnFamilyDescriptor[] columnFamilies = admin.getDescriptor(TableName.valueOf(dataTableFullName)) .getColumnFamilies(); assertEquals(3, columnFamilies.length); @@ -512,7 +517,7 @@ public void testSetPropertyAndAddColumnWhenTableHasExplicitDefaultColumnFamily() + dataTableFullName + " ADD col4 integer, CF1.col5 integer, CF2.col6 integer IN_MEMORY=true, CF1.BLOCKSIZE=50000, " + "CF2.IN_MEMORY=false, REPLICATION_SCOPE=1 "); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { ColumnFamilyDescriptor[] columnFamilies = admin.getDescriptor(TableName.valueOf(dataTableFullName)) .getColumnFamilies(); assertEquals(3, columnFamilies.length); @@ -570,7 +575,7 @@ public void testSetPropertyAndAddColumnForDifferentColumnFamilies() throws Excep "ALTER TABLE " + dataTableFullName + " ADD col4 integer, CF1.col5 integer, CF2.col6 integer, CF3.col7 integer CF1.BLOCKSIZE=50000, CF1.IN_MEMORY=false, IN_MEMORY=true "); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { ColumnFamilyDescriptor[] columnFamilies = admin.getDescriptor(TableName.valueOf(dataTableFullName)) .getColumnFamilies(); assertEquals(4, columnFamilies.length); @@ -607,7 +612,7 @@ public void testSetPropertyAndAddColumnUsingDefaultColumnFamilySpecifier() throw "ALTER TABLE " + dataTableFullName + " ADD col4 integer REPLICATION_SCOPE=1, XYZ.BLOCKSIZE=50000"); conn.createStatement() .execute("ALTER TABLE " + dataTableFullName + " ADD XYZ.col5 integer IN_MEMORY=true "); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { ColumnFamilyDescriptor[] columnFamilies = admin.getDescriptor(TableName.valueOf(dataTableFullName)) .getColumnFamilies(); assertEquals(2, columnFamilies.length); @@ -636,7 +641,7 @@ public void testSetPropertyAndAddColumnForDefaultColumnFamily() throws Exception try { conn.createStatement().execute(ddl); conn.createStatement().execute("ALTER TABLE " + dataTableFullName + " ADD col2 integer IN_MEMORY=true"); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { ColumnFamilyDescriptor[] columnFamilies = admin.getDescriptor(TableName.valueOf(dataTableFullName)) .getColumnFamilies(); assertEquals(1, columnFamilies.length); @@ -666,7 +671,7 @@ public void testAddNewColumnFamilyProperties() throws Exception { String ddl = "Alter table " + dataTableFullName + " add cf3.col5 integer, cf4.col6 integer in_memory=true"; conn.createStatement().execute(ddl); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { TableDescriptor tableDesc = admin.getDescriptor(TableName.valueOf(dataTableFullName)); assertTrue(tableDesc.isCompactionEnabled()); ColumnFamilyDescriptor[] columnFamilies = tableDesc.getColumnFamilies(); @@ -705,7 +710,7 @@ public void testAddProperyToExistingColumnFamily() throws Exception { String ddl = "Alter table " + dataTableFullName + " add cf1.col5 integer in_memory=true"; conn.createStatement().execute(ddl); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { TableDescriptor tableDesc = admin.getDescriptor(TableName.valueOf(dataTableFullName)); assertTrue(tableDesc.isCompactionEnabled()); ColumnFamilyDescriptor[] columnFamilies = tableDesc.getColumnFamilies(); @@ -782,7 +787,7 @@ public void testSetTTLForTableWithOnlyPKCols() throws Exception { + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1, col2)" + " ) " + generateDDLOptions("TTL=86400, SALT_BUCKETS = 4, DEFAULT_COLUMN_FAMILY='XYZ'"); conn.createStatement().execute(ddl); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { TableDescriptor tableDesc = admin.getDescriptor(TableName.valueOf(dataTableFullName)); ColumnFamilyDescriptor[] columnFamilies = tableDesc.getColumnFamilies(); assertEquals(1, columnFamilies.length); @@ -795,7 +800,7 @@ public void testSetTTLForTableWithOnlyPKCols() throws Exception { ddl = "ALTER TABLE " + dataTableFullName + " SET TTL=30"; conn.createStatement().execute(ddl); conn.commit(); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { TableDescriptor tableDesc = admin.getDescriptor(TableName.valueOf(dataTableFullName)); ColumnFamilyDescriptor[] columnFamilies = tableDesc.getColumnFamilies(); assertEquals(1, columnFamilies.length); @@ -823,27 +828,27 @@ public void testSetTTLForTableWithForeverAndNoneValue() throws Exception { + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1, col2)" + " ) " + generateDDLOptions("TTL=NONE, SALT_BUCKETS = 4, DEFAULT_COLUMN_FAMILY='XYZ'"); conn.createStatement().execute(ddl); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { TableDescriptor tableDesc = admin.getDescriptor(TableName.valueOf(dataTableFullName)); ColumnFamilyDescriptor[] columnFamilies = tableDesc.getColumnFamilies(); assertEquals(1, columnFamilies.length); assertEquals("XYZ", columnFamilies[0].getNameAsString()); assertEquals(HConstants.FOREVER, columnFamilies[0].getTimeToLive()); //Check if TTL is stored in SYSCAT as well and we are getting ttl from get api in PTable - assertEquals(TTL_EXPRESSION_NOT_DEFINED, conn.unwrap(PhoenixConnection.class).getTable( + assertEquals(TTL_EXPRESSION_NOT_DEFINED, conn.unwrap(PhoenixMonitoredConnection.class).getTable( new PTableKey(null, dataTableFullName)).getTTLExpression()); } ddl = "ALTER TABLE " + dataTableFullName + " SET TTL=FOREVER"; conn.createStatement().execute(ddl); conn.commit(); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { TableDescriptor tableDesc = admin.getDescriptor(TableName.valueOf(dataTableFullName)); ColumnFamilyDescriptor[] columnFamilies = tableDesc.getColumnFamilies(); assertEquals(1, columnFamilies.length); assertEquals(HConstants.FOREVER, columnFamilies[0].getTimeToLive()); assertEquals("XYZ", columnFamilies[0].getNameAsString()); //Check if Alter Table TTL also changes TTL stored in SYSCAT - assertEquals(TTL_EXPRESSION_NOT_DEFINED, conn.unwrap(PhoenixConnection.class).getTable( + assertEquals(TTL_EXPRESSION_NOT_DEFINED, conn.unwrap(PhoenixMonitoredConnection.class).getTable( new PTableKey(null, dataTableFullName)).getTTLExpression()); } } finally { @@ -867,7 +872,7 @@ public void testSetHColumnPropertyForTableWithOnlyPKCols1() throws Exception { ddl = "ALTER TABLE " + dataTableFullName + " SET IN_MEMORY=true"; conn.createStatement().execute(ddl); conn.commit(); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { TableDescriptor tableDesc = admin.getDescriptor(TableName.valueOf(dataTableFullName)); ColumnFamilyDescriptor[] columnFamilies = tableDesc.getColumnFamilies(); assertEquals(1, columnFamilies.length); @@ -895,7 +900,7 @@ public void testSetHColumnPropertyForTableWithOnlyPKCols2() throws Exception { ddl = "ALTER TABLE " + dataTableFullName + " SET IN_MEMORY=true"; conn.createStatement().execute(ddl); conn.commit(); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { TableDescriptor tableDesc = admin.getDescriptor(TableName.valueOf(dataTableFullName)); ColumnFamilyDescriptor[] columnFamilies = tableDesc.getColumnFamilies(); assertEquals(1, columnFamilies.length); @@ -923,7 +928,7 @@ public void testSetHColumnPropertyAndAddColumnForDefaultCFForTableWithOnlyPKCols ddl = "ALTER TABLE " + dataTableFullName + " ADD COL3 INTEGER IN_MEMORY=true"; conn.createStatement().execute(ddl); conn.commit(); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { TableDescriptor tableDesc = admin.getDescriptor(TableName.valueOf(dataTableFullName)); ColumnFamilyDescriptor[] columnFamilies = tableDesc.getColumnFamilies(); assertEquals(1, columnFamilies.length); @@ -951,7 +956,7 @@ public void testSetHColumnPropertyAndAddColumnForNewCFForTableWithOnlyPKCols() t ddl = "ALTER TABLE " + dataTableFullName + " ADD NEWCF.COL3 INTEGER IN_MEMORY=true"; conn.createStatement().execute(ddl); conn.commit(); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { TableDescriptor tableDesc = admin.getDescriptor(TableName.valueOf(dataTableFullName)); ColumnFamilyDescriptor[] columnFamilies = tableDesc.getColumnFamilies(); assertEquals(2, columnFamilies.length); @@ -981,7 +986,7 @@ public void testTTLAssignmentForNewEmptyCF() throws Exception { ddl = "ALTER TABLE " + dataTableFullName + " ADD NEWCF.COL3 INTEGER IN_MEMORY=true"; conn.createStatement().execute(ddl); conn.commit(); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { TableDescriptor tableDesc = admin.getDescriptor(TableName.valueOf(dataTableFullName)); ColumnFamilyDescriptor[] columnFamilies = tableDesc.getColumnFamilies(); assertEquals(2, columnFamilies.length); @@ -999,7 +1004,7 @@ public void testTTLAssignmentForNewEmptyCF() throws Exception { ddl = "ALTER TABLE " + dataTableFullName + " SET TTL=1000"; conn.createStatement().execute(ddl); conn.commit(); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { TableDescriptor tableDesc = admin.getDescriptor(TableName.valueOf(dataTableFullName)); ColumnFamilyDescriptor[] columnFamilies = tableDesc.getColumnFamilies(); assertEquals(2, columnFamilies.length); @@ -1020,7 +1025,7 @@ public void testTTLAssignmentForNewEmptyCF() throws Exception { ddl = "ALTER TABLE " + dataTableFullName + " ADD COL3 INTEGER"; conn.createStatement().execute(ddl); conn.commit(); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { TableDescriptor tableDesc = admin.getDescriptor(TableName.valueOf(dataTableFullName)); ColumnFamilyDescriptor[] columnFamilies = tableDesc.getColumnFamilies(); assertEquals(2, columnFamilies.length); @@ -1057,7 +1062,7 @@ public void testSettingNotHColumnNorPhoenixPropertyEndsUpAsHTableProperty() thro } ddl = "ALTER TABLE " + dataTableFullName + " SET UNKNOWN_PROP='ABC'"; conn.createStatement().execute(ddl); - try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { TableDescriptor tableDesc = admin.getDescriptor(TableName.valueOf(dataTableFullName)); assertEquals("ABC", tableDesc.getValue("UNKNOWN_PROP")); } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SetPropertyOnEncodedTableIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SetPropertyOnEncodedTableIT.java index 42653ac53da..42a074976bf 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SetPropertyOnEncodedTableIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SetPropertyOnEncodedTableIT.java @@ -22,7 +22,6 @@ import org.junit.experimental.categories.Category; import org.junit.runners.Parameterized.Parameters; - @Category(NeedsOwnMiniClusterTest.class) public class SetPropertyOnEncodedTableIT extends SetPropertyIT { public SetPropertyOnEncodedTableIT(boolean columnEncoded) { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SetPropertyOnNonEncodedTableIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SetPropertyOnNonEncodedTableIT.java index 6a9c4ab01b4..1b7d8ea49b1 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SetPropertyOnNonEncodedTableIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SetPropertyOnNonEncodedTableIT.java @@ -22,7 +22,6 @@ import org.junit.experimental.categories.Category; import org.junit.runners.Parameterized.Parameters; - @Category(NeedsOwnMiniClusterTest.class) public class SetPropertyOnNonEncodedTableIT extends SetPropertyIT { public SetPropertyOnNonEncodedTableIT(boolean columnEncoded) { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ShowCreateTableIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ShowCreateTableIT.java index 051281d18d8..81697b1c7f3 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ShowCreateTableIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ShowCreateTableIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.SchemaUtil; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -29,13 +30,13 @@ import static org.apache.phoenix.query.QueryConstants.DEFAULT_COLUMN_FAMILY; import static org.apache.phoenix.query.QueryConstants.ENCODED_CQ_COUNTER_INITIAL_VALUE; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertTrue; - @Category(ParallelStatsDisabledTest.class) public class ShowCreateTableIT extends ParallelStatsDisabledIT { @Test public void testShowCreateTableBasic() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + "(K VARCHAR NOT NULL PRIMARY KEY, INT INTEGER, INT2 INTEGER)"; @@ -52,7 +53,7 @@ public void testShowCreateTableBasic() throws Exception { @Test public void testShowCreateTableLowerCase() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = "lowercasetbl1"; String ddl = "CREATE TABLE \"" + tableName + "\"(K VARCHAR NOT NULL PRIMARY KEY, INT INTEGER)"; @@ -69,7 +70,7 @@ public void testShowCreateTableLowerCase() throws Exception { @Test public void testShowCreateTableUpperCase() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); String schemaName = generateUniqueName(); @@ -88,7 +89,7 @@ public void testShowCreateTableUpperCase() throws Exception { @Test public void testShowCreateTableDefaultFamily() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); String ddl = "CREATE IMMUTABLE TABLE \"" + tableName + "\"(K VARCHAR NOT NULL PRIMARY KEY, " + @@ -114,7 +115,7 @@ public void testShowCreateTableDefaultFamily() throws Exception { @Test public void testShowCreateTableDefaultFamilyNonConsecutive() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); String ddl = "CREATE IMMUTABLE TABLE \"" + tableName + "\"(K VARCHAR NOT NULL PRIMARY KEY, " + @@ -146,7 +147,7 @@ public void testShowCreateTableDefaultFamilyNonConsecutive() throws Exception { @Test public void testShowCreateTableCounter() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + "(K VARCHAR NOT NULL PRIMARY KEY, " + @@ -164,7 +165,7 @@ public void testShowCreateTableCounter() throws Exception { @Test public void testShowCreateTableColumnQualifierNonConsecutive() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + "(K VARCHAR NOT NULL PRIMARY KEY, " + @@ -224,7 +225,7 @@ public void testShowCreateTableColumnQualifierNonConsecutive() throws Exception @Test public void testShowCreateTableColumnQualifierDropAndAdd() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName();; String ddl = "CREATE TABLE " + tableName + "(K VARCHAR NOT NULL PRIMARY KEY, " + @@ -251,7 +252,7 @@ public void testShowCreateTableColumnQualifierDropAndAdd() throws Exception { @Test public void testShowCreateTableColumnQualifierMultipleFamilies() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName();; String ddl = "CREATE IMMUTABLE TABLE " + tableName + @@ -269,7 +270,7 @@ public void testShowCreateTableColumnQualifierMultipleFamilies() throws Exceptio @Test public void testShowCreateTableColumnQualifierMultipleFamiliesNonConsecutive() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName();; String ddl = "CREATE IMMUTABLE TABLE " + tableName + @@ -316,7 +317,7 @@ public void testShowCreateTableColumnQualifierMultipleFamiliesNonConsecutive() t @Test public void testShowCreateTableView() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); String viewName = generateUniqueName(); @@ -337,7 +338,7 @@ public void testShowCreateTableView() throws Exception { @Test public void testShowCreateTableIndex() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); String indexname = generateUniqueName(); @@ -353,7 +354,7 @@ public void testShowCreateTableIndex() throws Exception { @Test public void testShowCreateTableUsingGetResultSet() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); String schemaName = generateUniqueName(); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SignFunctionEnd2EndIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SignFunctionEnd2EndIT.java index b0942f2a832..a67aafeac3c 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SignFunctionEnd2EndIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SignFunctionEnd2EndIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.apache.phoenix.util.TestUtil.closeStmtAndConn; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -28,6 +29,7 @@ import java.sql.ResultSet; import org.apache.phoenix.expression.function.SignFunction; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -50,7 +52,7 @@ public void initTable() throws Exception { Connection conn = null; PreparedStatement stmt = null; try { - conn = DriverManager.getConnection(getUrl()); + conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String ddl; ddl = "CREATE TABLE " + signedTableName + " (k VARCHAR NOT NULL PRIMARY KEY, \"DEC\" DECIMAL, doub DOUBLE, fl FLOAT, inte INTEGER, lon BIGINT, smalli SMALLINT, tinyi TINYINT)"; @@ -139,7 +141,7 @@ private void testUnsignedNumberSpec(Connection conn, double data, int expected) @Test public void testSignedNumber() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)); testSignedNumberSpec(conn, 0.0, 0); testSignedNumberSpec(conn, 1.0, 1); testSignedNumberSpec(conn, -1.0, -1); @@ -149,7 +151,7 @@ public void testSignedNumber() throws Exception { @Test public void testUnsignedNumber() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)); testUnsignedNumberSpec(conn, 0.0, 0); testUnsignedNumberSpec(conn, 1.0, 1); testUnsignedNumberSpec(conn, 123.1234, 1); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipScanAfterManualSplitIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipScanAfterManualSplitIT.java index 22361c7eb33..7bbe8f1d8a6 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipScanAfterManualSplitIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipScanAfterManualSplitIT.java @@ -35,6 +35,7 @@ import org.apache.hadoop.hbase.client.TableDescriptorBuilder; import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.ConnectionQueryServices; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.query.QueryServicesOptions; @@ -43,7 +44,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class SkipScanAfterManualSplitIT extends ParallelStatsDisabledIT { @@ -89,7 +89,7 @@ private static void initTable(String tableName) throws Exception { } } conn.commit(); - ConnectionQueryServices services = conn.unwrap(PhoenixConnection.class).getQueryServices(); + ConnectionQueryServices services = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); Admin admin = services.getAdmin(); try { admin.flush(TableName.valueOf(tableName)); @@ -105,7 +105,7 @@ public void testManualSplit() throws Exception { byte[] tableNameBytes = Bytes.toBytes(tableName); initTable(tableName); Connection conn = getConnection(); - ConnectionQueryServices services = conn.unwrap(PhoenixConnection.class).getQueryServices(); + ConnectionQueryServices services = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); int queryTimeout = services.getProps() .getInt(QueryServices.THREAD_TIMEOUT_MS_ATTRIB, QueryServicesOptions.DEFAULT_THREAD_TIMEOUT_MS); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipScanQueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipScanQueryIT.java index 45a1a56d798..1f04f9bd516 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipScanQueryIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipScanQueryIT.java @@ -46,6 +46,7 @@ import org.apache.phoenix.compile.ExplainPlan; import org.apache.phoenix.compile.QueryPlan; import org.apache.phoenix.filter.SkipScanFilter; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixPreparedStatement; import org.apache.phoenix.jdbc.PhoenixStatement; import org.apache.phoenix.util.TestUtil; @@ -56,7 +57,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class SkipScanQueryIT extends ParallelStatsDisabledIT { @@ -169,7 +169,7 @@ public void testSkipScanFilterQuery() throws Exception { @Test public void testSelectAfterUpsertInQuery() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = initSelectAfterUpsertTable(conn); try { String query; @@ -185,7 +185,7 @@ public void testSelectAfterUpsertInQuery() throws Exception { } @Test public void testInQuery() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.setAutoCommit(false); String tableName = initIntInTable(conn,Arrays.asList(2,7,10)); try { @@ -206,7 +206,7 @@ public void testInQuery() throws Exception { @Test public void testVarCharParallelListInQuery() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.setAutoCommit(false); String tableName = initVarCharParallelListInTable(conn,Arrays.asList("d","da","db"),Arrays.asList("m","mc","tt")); try { @@ -224,7 +224,7 @@ public void testVarCharParallelListInQuery() throws Exception { @Test public void testVarCharXInQuery() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.setAutoCommit(false); String tableName = initVarCharCrossProductInTable(conn,Arrays.asList("d","da","db"),Arrays.asList("m","mc","tt")); try { @@ -251,7 +251,7 @@ public void testVarCharXInQuery() throws Exception { @Test public void testVarCharXIntInQuery() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.setAutoCommit(false); String tableName = initVarCharCrossProductInTable(conn,Arrays.asList("d","da","db"),Arrays.asList("m","mc","tt")); try { @@ -272,7 +272,7 @@ public void testVarCharXIntInQuery() throws Exception { @Test public void testPreSplitCompositeFixedKey() throws Exception { String tableName = generateUniqueName(); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { conn.createStatement().execute("create table " + tableName + "(key_1 char(3) not null, key_2 char(4) not null, v varchar(8) CONSTRAINT pk PRIMARY KEY (key_1,key_2)) split on('000','100','200')"); conn.setAutoCommit(true); @@ -300,7 +300,7 @@ public void testPreSplitCompositeFixedKey() throws Exception { @Test public void testInWithDescKey() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); try { conn.createStatement().execute("create table " + tableName + "(key_1 char(3) not null, key_2 char(4) not null, v varchar(8) CONSTRAINT pk PRIMARY KEY (key_1,key_2 desc))"); @@ -340,7 +340,7 @@ public void testInWithDescKey() throws Exception { @Test public void testSkipScanIntersectionAtEnd() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); conn.createStatement() .execute( @@ -450,7 +450,7 @@ public void testSkipScanFilterWhenTableHasMultipleColumnFamilies() throws Except @Test public void testOrPKWithAndNonPK() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); try { conn.createStatement().execute("create table " + tableName + "(ID varchar primary key,company varchar)"); @@ -471,7 +471,7 @@ public void testOrPKWithAndNonPK() throws Exception { @Test public void testNullInfiniteLoop() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tableName = generateUniqueName(); conn.setAutoCommit(true); conn.createStatement().execute( @@ -494,7 +494,7 @@ public void testNullInfiniteLoop() throws Exception { @Test public void testSkipScanQueryWhenSplitKeyIsSmaller() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tableName = generateUniqueName(); StringBuffer buf = new StringBuffer("CREATE TABLE IF NOT EXISTS " + tableName @@ -544,7 +544,7 @@ public void testSkipScanQueryWhenSplitKeyIsSmaller() throws Exception { stmt.executeUpdate(); conn.commit(); try (Admin admin = - conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { /* * The split key is 27 bytes instead of at least 30 bytes (CHAR(15) + CHAR(15)). * Note that we cannot use the phoenix way of giving split points in the ddl because @@ -580,7 +580,7 @@ public void testSkipScanQueryWhenSplitKeyIsSmaller() throws Exception { @Test public void testSkipScanJoinOptimization() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tableName = generateUniqueName(); String viewName = generateUniqueName(); String idxName = "IDX_" + tableName; @@ -602,7 +602,7 @@ public void testSkipScanJoinOptimization() throws Exception { @Test public void testOrWithMixedOrderPKs() throws Exception { String tableName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.setAutoCommit(true); Statement stmt = conn.createStatement(); @@ -666,7 +666,7 @@ public void testOrWithMixedOrderPKs() throws Exception { @Test public void testRVCClipBug5753() throws Exception { String tableName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.setAutoCommit(true); Statement stmt = conn.createStatement(); @@ -724,7 +724,7 @@ public void testRVCBug6659() throws Exception { String tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + " (PK1 VARCHAR NOT NULL, PK2 INTEGER NOT NULL, " + "PK3 BIGINT NOT NULL CONSTRAINT PK PRIMARY KEY (PK1,PK2,PK3))"; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute(ddl); conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES('a',0,1)"); conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES('a',1,1)"); @@ -750,7 +750,7 @@ public void testRVCBug6659_Delete() throws Exception { String tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + " (PK1 DOUBLE NOT NULL, PK2 INTEGER NOT NULL, " + " CONSTRAINT PK PRIMARY KEY (PK1,PK2))"; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute(ddl); conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES(10.0,10)"); conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES(20.0,20)"); @@ -769,7 +769,7 @@ public void testRVCBug6659_AllVarchar() throws Exception { String tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + " (PK1 VARCHAR NOT NULL, PK2 VARCHAR NOT NULL, " + "PK3 BIGINT NOT NULL CONSTRAINT PK PRIMARY KEY (PK1,PK2,PK3))"; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute(ddl); conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES('a','0',1)"); conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES('a','1',1)"); @@ -794,7 +794,7 @@ public void testRVCBug6659_IntVarcharBigint() throws Exception { String tableName = generateUniqueName(); String ddl = "CREATE TABLE " + tableName + " (PK1 INTEGER NOT NULL, PK2 VARCHAR NOT NULL, " + "PK3 BIGINT NOT NULL CONSTRAINT PK PRIMARY KEY (PK1,PK2,PK3))"; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute(ddl); conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES(1,'0',1)"); conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES(1,'1',1)"); @@ -844,7 +844,7 @@ public void testRvcInListDelete() throws Exception { createTestTable(getUrl(), baseTableDDL); createTestTable(getUrl(), globalViewDDL); - Properties tenantProps = new Properties(); + Properties tenantProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, "tenant1"); String upsertOne = "UPSERT INTO " + tenantViewName + " (DOUBLE1, INT1) VALUES (10.0,10)"; String upsertTwo = "UPSERT INTO " + tenantViewName + " (DOUBLE1, INT1) VALUES (20.0,20)"; @@ -920,7 +920,7 @@ public void testRvcInListDeleteBothDesc() throws Exception { createTestTable(getUrl(), baseTableDDL); createTestTable(getUrl(), globalViewDDL); - Properties tenantProps = new Properties(); + Properties tenantProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, "tenant1"); String upsertOne = "UPSERT INTO " + tenantViewName + " (DOUBLE1, INT1) VALUES (10.0,10)"; String upsertTwo = "UPSERT INTO " + tenantViewName + " (DOUBLE1, INT1) VALUES (20.0,20)"; @@ -985,7 +985,7 @@ public void testPHOENIX6669() throws SQLException { " PK4\n" + " )\n" + ")"; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute(ddl); conn.createStatement().execute("UPSERT INTO " + tableName + " (PK1, PK4, COL1, PK2, COL2, PK3, COL3, COL4)" + " VALUES ('xx', 'xid1', 0, 7, 7, 7, 'INSERT', null)"); @@ -1014,7 +1014,7 @@ public void testKeyRangesContainsAllValues() throws Exception { " count2 INTEGER, " + " CONSTRAINT PK PRIMARY KEY (vdate,tab,dev,app,target,channel,one,two))"; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute(ddl); conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES('2018-02-14','channel_agg',2,null,null,'A004',null,null,2,2)"); conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES('2018-02-14','channel_agg',2,null,null,null,null,null,2,2)"); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortMergeJoinMoreIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortMergeJoinMoreIT.java index fe64d7dfc65..ca94f5f3790 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortMergeJoinMoreIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortMergeJoinMoreIT.java @@ -34,7 +34,6 @@ import org.apache.phoenix.util.QueryUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class SortMergeJoinMoreIT extends ParallelStatsDisabledIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java index e52dbb4e23c..01982a24d25 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderIT.java @@ -57,7 +57,6 @@ * @since 1.2 */ - @Category(ParallelStatsDisabledTest.class) public class SortOrderIT extends ParallelStatsDisabledIT { protected String baseTableName; @@ -302,7 +301,7 @@ public void decimalRangeDescPK1() throws Exception { String table = generateUniqueName(); TABLE_NAMES.add(table); String ddl = "CREATE table " + table + " (oid DECIMAL PRIMARY KEY DESC)"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); conn.createStatement().execute("UPSERT INTO " + table + " VALUES(4.99)"); conn.createStatement().execute("UPSERT INTO " + table + " VALUES(4.0)"); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderWithRegionMoves2IT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderWithRegionMoves2IT.java index ef317ec4c53..d773acabf8c 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderWithRegionMoves2IT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderWithRegionMoves2IT.java @@ -36,6 +36,7 @@ import java.util.HashMap; import java.util.Map; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; @Category(NeedsOwnMiniClusterTest.class) public class SortOrderWithRegionMoves2IT extends SortOrderIT { @@ -90,7 +91,11 @@ public static synchronized void doSetup() throws Exception { props.put(HConstants.HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY, String.valueOf(1)); props.put(QueryServices.PHOENIX_POST_VALID_PROCESS, TestScanningResultPostValidResultCaller.class.getName()); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @AfterClass diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderWithRegionMovesIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderWithRegionMovesIT.java index d98f74f6250..0ad316a75ff 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderWithRegionMovesIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortOrderWithRegionMovesIT.java @@ -49,6 +49,8 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; + @Category(NeedsOwnMiniClusterTest.class) public class SortOrderWithRegionMovesIT extends SortOrderIT { @@ -128,8 +130,11 @@ public static synchronized void doSetup() throws Exception { TestScanningResultPostDummyResultCaller.class.getName()); props.put(QueryServices.PHOENIX_POST_VALID_PROCESS, TestScanningResultPostValidResultCaller.class.getName()); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); - } + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @AfterClass public static synchronized void freeResources() throws Exception { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpillableGroupByIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpillableGroupByIT.java index 091a29e984e..50662f09872 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpillableGroupByIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpillableGroupByIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.apache.phoenix.util.TestUtil.createGroupByTestTable; import static org.junit.Assert.assertEquals; @@ -51,7 +52,6 @@ * and we wouldn't want that to be set for other tests sharing the same * cluster. */ - @Category(NeedsOwnMiniClusterTest.class) public class SpillableGroupByIT extends BaseOwnClusterIT { @@ -85,7 +85,11 @@ public static synchronized void doSetup() throws Exception { props.put(QueryServices.EXPLAIN_ROW_COUNT_ATTRIB, Boolean.TRUE.toString()); props.put(QueryServices.PHOENIX_SERVER_PAGE_SIZE_MS, Long.toString(60000)); // Must update config before starting server - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()), new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } private void createTable(Connection conn, String tableName) throws Exception { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SplitSystemCatalogIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SplitSystemCatalogIT.java index 852e98e67c3..d06b931d1c7 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SplitSystemCatalogIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SplitSystemCatalogIT.java @@ -25,6 +25,7 @@ import java.util.Map; import org.apache.phoenix.query.BaseTest; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; import org.junit.BeforeClass; @@ -32,6 +33,8 @@ import org.apache.phoenix.thirdparty.com.google.common.collect.Lists; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; /** * Base class for tests that run with split SYSTEM.CATALOG. * @@ -58,7 +61,11 @@ public static synchronized void doSetup(Map props) props = Collections.emptyMap(); } boolean splitSystemCatalog = (driver == null); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } // Split SYSTEM.CATALOG once after the mini-cluster is started if (splitSystemCatalog) { // splitSystemCatalog is incompatible with the balancer chore @@ -68,7 +75,7 @@ public static synchronized void doSetup(Map props) } protected static void splitSystemCatalog() throws Exception { - try (Connection ignored = DriverManager.getConnection(getUrl())) { + try (Connection ignored = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { } String tableName = "TABLE"; String fullTableName1 = SchemaUtil.getTableName(SCHEMA1, tableName); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledTmpFileDeleteIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledTmpFileDeleteIT.java index 1acec125ae8..4e143905213 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledTmpFileDeleteIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SpooledTmpFileDeleteIT.java @@ -34,7 +34,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class SpooledTmpFileDeleteIT extends ParallelStatsDisabledIT { private static final String PRINCIPAL = "noRenewLease"; @@ -50,7 +49,7 @@ private Connection getConnection() throws Exception { // TODO: review with Samarth - should a Noop iterator be used if pacing is not possible? props.setProperty(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, Boolean.toString(true)); props.setProperty(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, StringUtil.EMPTY_STRING); - String url = QueryUtil.getConnectionUrl(props, config, PRINCIPAL); + String url = QueryUtil.getConnectionUrl(props, getConfiguration(), PRINCIPAL); return DriverManager.getConnection(url, props); } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SqrtFunctionEnd2EndIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SqrtFunctionEnd2EndIT.java index f4fb4ff05ed..0797cfdf2e3 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SqrtFunctionEnd2EndIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SqrtFunctionEnd2EndIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.apache.phoenix.util.TestUtil.closeStmtAndConn; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -27,6 +28,7 @@ import java.sql.ResultSet; import org.apache.phoenix.expression.function.SqrtFunction; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -49,7 +51,7 @@ public void initTable() throws Exception { testUnsignedTable = generateUniqueName(); testSignedTable = generateUniqueName(); try { - conn = DriverManager.getConnection(getUrl()); + conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String ddl; ddl = "CREATE TABLE " + testSignedTable + " (k VARCHAR NOT NULL PRIMARY KEY, doub DOUBLE, fl FLOAT, inte INTEGER, lon BIGINT, smalli SMALLINT, tinyi TINYINT)"; conn.createStatement().execute(ddl); @@ -133,7 +135,7 @@ private void testUnsignedNumberSpec(Connection conn, double data) throws Excepti @Test public void testSignedNumber() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); for (double d : new double[] { 0.0, 1.0, 123.1234}) { testSignedNumberSpec(conn, d); } @@ -141,7 +143,7 @@ public void testSignedNumber() throws Exception { @Test public void testUnsignedNumber() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); for (double d : new double[] { 0.0, 1.0, 123.1234 }) { testUnsignedNumberSpec(conn, d); } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatementHintsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatementHintsIT.java index 4d7bb8351a5..d02474513d8 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatementHintsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatementHintsIT.java @@ -37,7 +37,6 @@ * End-to-End tests on various statement hints. */ - @Category(ParallelStatsDisabledTest.class) public class StatementHintsIT extends ParallelStatsDisabledIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatsEnabledSplitSystemCatalogIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatsEnabledSplitSystemCatalogIT.java index 02a91373606..e4bf7679bec 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatsEnabledSplitSystemCatalogIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/StatsEnabledSplitSystemCatalogIT.java @@ -17,8 +17,10 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.util.TestUtil.analyzeTable; import static org.apache.phoenix.util.TestUtil.getAllSplits; +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; @@ -42,12 +44,14 @@ import org.apache.hadoop.hbase.util.Pair; import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.BaseTest; import org.apache.phoenix.query.KeyRange; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.ReadOnlyTableException; import org.apache.phoenix.transaction.PhoenixTransactionProvider.Feature; import org.apache.phoenix.transaction.TransactionFactory; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.ScanUtil; import org.apache.phoenix.util.SchemaUtil; @@ -60,7 +64,6 @@ import org.junit.runners.Parameterized.Parameters; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; - @Category(NeedsOwnMiniClusterTest.class) @RunWith(Parameterized.class) public class StatsEnabledSplitSystemCatalogIT extends BaseTest { @@ -91,7 +94,11 @@ public static synchronized void doSetup() throws Exception { props.put(QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, Long.toString(20)); props.put(QueryServices.STATS_UPDATE_FREQ_MS_ATTRIB, Long.toString(5)); props.put(QueryServices.USE_STATS_FOR_PARALLELIZATION, Boolean.toString(true)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } /** @@ -136,7 +143,7 @@ public void testUpdatableOnUpdatableView() throws Exception { String fullViewName2 = SchemaUtil.getTableName(generateUniqueName(), generateUniqueName()); String ddl = "CREATE VIEW " + fullViewName2 + " AS SELECT * FROM " + fullViewName1 + " WHERE k3 = 2"; ViewIT.testUpdatableView(fullTableName, fullViewName1, fullViewName2, ddl, null, tableDDLOptions); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery("SELECT k1, k2, k3 FROM " + fullViewName2); assertTrue(rs.next()); assertEquals(1, rs.getInt(1)); @@ -179,8 +186,8 @@ private void testUpdatableViewWithIndex(Integer saltBuckets, boolean localIndex) String physicalTableName = pair.getFirst(); // Confirm that dropping the view also deletes the rows in the index if (saltBuckets == null) { - try (Connection conn = DriverManager.getConnection(getUrl())) { - Table htable = conn.unwrap(PhoenixConnection.class).getQueryServices() + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { + Table htable = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices() .getTable(Bytes.toBytes(physicalTableName)); if (ScanUtil.isLocalIndex(scan)) { ScanUtil.setLocalIndexAttributes(scan, 0, HConstants.EMPTY_BYTE_ARRAY, HConstants.EMPTY_BYTE_ARRAY, @@ -203,8 +210,8 @@ private void testUpdatableViewWithIndex(Integer saltBuckets, boolean localIndex) @Test public void testReadOnlyOnReadOnlyView() throws Exception { - Connection earlierCon = DriverManager.getConnection(getUrl()); - Connection conn = DriverManager.getConnection(getUrl()); + Connection earlierCon = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String fullTableName = SchemaUtil.getTableName(generateUniqueName(), generateUniqueName()); String fullParentViewName = SchemaUtil.getTableName(generateUniqueName(), generateUniqueName()); String fullViewName = SchemaUtil.getTableName(generateUniqueName(), generateUniqueName()); @@ -263,7 +270,7 @@ public void testReadOnlyOnReadOnlyView() throws Exception { conn.close(); } - conn = DriverManager.getConnection(getUrl()); + conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); count = 0; rs = conn.createStatement().executeQuery("SELECT k FROM " + fullViewName); while (rs.next()) { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StddevIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/StddevIT.java index c6298d2d300..f2f617797d0 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StddevIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/StddevIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +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; @@ -28,9 +29,9 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class StddevIT extends ParallelStatsDisabledIT { @@ -40,8 +41,7 @@ public void testSTDDEV_POP() throws Exception { String tableName = initATableValues(tenantId, getDefaultSplits(tenantId), getUrl()); String query = "SELECT STDDEV_POP(A_INTEGER) FROM " + tableName; - - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { PreparedStatement statement = conn.prepareStatement(query); ResultSet rs = statement.executeQuery(); @@ -61,8 +61,7 @@ public void testSTDDEV_SAMP() throws Exception { String tableName = initATableValues(tenantId, getDefaultSplits(tenantId), getUrl()); String query = "SELECT STDDEV_SAMP(x_decimal) FROM " + tableName; - - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { PreparedStatement statement = conn.prepareStatement(query); ResultSet rs = statement.executeQuery(); @@ -82,8 +81,7 @@ public void testSTDDEV_POPOnDecimalColType() throws Exception { String tableName = initATableValues(tenantId, getDefaultSplits(tenantId), getUrl()); String query = "SELECT STDDEV_POP(x_decimal) FROM " + tableName; - - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { PreparedStatement statement = conn.prepareStatement(query); ResultSet rs = statement.executeQuery(); @@ -103,8 +101,7 @@ public void testSTDDEV_SAMPOnDecimalColType() throws Exception { String tableName = initATableValues(tenantId, getDefaultSplits(tenantId), getUrl()); String query = "SELECT STDDEV_SAMP(x_decimal) FROM " + tableName; - - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { PreparedStatement statement = conn.prepareStatement(query); ResultSet rs = statement.executeQuery(); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StoreNullsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/StoreNullsIT.java index 6c006e81c9b..8350bcae57b 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StoreNullsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/StoreNullsIT.java @@ -17,6 +17,8 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +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.assertNull; @@ -46,6 +48,7 @@ import org.apache.phoenix.expression.SingleCellColumnExpression; import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.QueryConstants; import org.apache.phoenix.schema.PColumn; import org.apache.phoenix.schema.PTable; @@ -92,8 +95,11 @@ public class StoreNullsIT extends ParallelStatsDisabledIT { public static synchronized void doSetup() throws Exception { Map props = Maps.newHashMapWithExpectedSize(1); props.put(BaseScannerRegionObserverConstants.PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY, Integer.toString(0)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); - } + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } public StoreNullsIT(boolean mutable, boolean columnEncoded, boolean storeNulls) { this.mutable = mutable; @@ -133,7 +139,7 @@ public void setupTableNames() throws Exception { @Test public void testStoringNullsForImmutableTables() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { conn.setAutoCommit(true); stmt.execute(String.format(ddlFormat, dataTableName)); @@ -159,7 +165,7 @@ private void ensureNullsStoredCorrectly(Connection conn) throws Exception { ResultScanner scanner = htable.getScanner(s); // first row has a value for name Result rs = scanner.next(); - PTable table = conn.unwrap(PhoenixConnection.class).getTable(new PTableKey(null, dataTableName)); + PTable table = conn.unwrap(PhoenixMonitoredConnection.class).getTable(new PTableKey(null, dataTableName)); PColumn nameColumn = table.getColumnForColumnName("NAME"); byte[] qualifier = table.getImmutableStorageScheme()== ImmutableStorageScheme.SINGLE_CELL_ARRAY_WITH_OFFSETS ? QueryConstants.SINGLE_KEYVALUE_COLUMN_QUALIFIER_BYTES : nameColumn.getColumnQualifierBytes(); assertTrue(rs.containsColumn(QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES, qualifier)); @@ -195,7 +201,7 @@ private void ensureNullsStoredCorrectly(Connection conn) throws Exception { @Test public void testQueryingHistory() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { conn.setAutoCommit(true); stmt.execute(String.format(ddlFormat, dataTableName)); @@ -209,7 +215,7 @@ public void testQueryingHistory() throws Exception { TestUtil.doMajorCompaction(conn, dataTableName); - Properties historicalProps = new Properties(); + Properties historicalProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); historicalProps.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(afterFirstInsert)); Connection historicalConn = DriverManager.getConnection(getUrl(), historicalProps); @@ -238,7 +244,7 @@ public void testQueryingHistory() throws Exception { // Row deletes should work in the same way regardless of what STORE_NULLS is set to @Test public void testDeletes() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { conn.setAutoCommit(true); stmt.execute(String.format(ddlFormat, dataTableName)); @@ -251,7 +257,7 @@ public void testDeletes() throws Exception { stmt.executeUpdate("DELETE FROM " + dataTableName + " WHERE id = 1"); Thread.sleep(10L); TestUtil.doMajorCompaction(conn, dataTableName); - Properties historicalProps = new Properties(); + Properties historicalProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); historicalProps.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(afterFirstInsert)); Connection historicalConn = DriverManager.getConnection(getUrl(), historicalProps); @@ -288,7 +294,7 @@ public void testSetIndexedColumnToNullTwiceWithStoreNulls() throws Exception { String tableName = generateUniqueName(); String indexName = generateUniqueName(); - Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); conn.createStatement().execute("CREATE TABLE " + tableName + "(k1 CHAR(2) NOT NULL, k2 CHAR(2) NOT NULL, ts TIMESTAMP, V VARCHAR, V2 VARCHAR, " + "CONSTRAINT pk PRIMARY KEY (k1,k2)) STORE_NULLS=" + storeNulls + (columnEncoded ? "" : ",COLUMN_ENCODED_BYTES=0")); @@ -311,8 +317,8 @@ public void testSetIndexedColumnToNullTwiceWithStoreNulls() throws Exception { stmt.executeUpdate(); conn.commit(); - TestUtil.dumpTable(conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(Bytes.toBytes(tableName))); - TestUtil.dumpTable(conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(Bytes.toBytes(indexName))); + TestUtil.dumpTable(conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getTable(Bytes.toBytes(tableName))); + TestUtil.dumpTable(conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getTable(Bytes.toBytes(indexName))); long count1 = getRowCount(conn, tableName); long count2 = getRowCount(conn, indexName); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StoreNullsPropIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/StoreNullsPropIT.java index b6d547b7acb..f94d8fbbf30 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StoreNullsPropIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/StoreNullsPropIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertTrue; import java.sql.Connection; @@ -27,15 +28,15 @@ import java.util.Properties; import org.apache.phoenix.query.QueryServices; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class StoreNullsPropIT extends ParallelStatsDisabledIT { @Test public void testSetStoreNullsDefaultViaConfig() throws SQLException { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.DEFAULT_STORE_NULLS_ATTRIB, "true"); Connection storeNullsConn = DriverManager.getConnection(getUrl(), props); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StringIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/StringIT.java index 692bde297e7..4a021ac3922 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StringIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/StringIT.java @@ -43,7 +43,6 @@ /** * Tests for the LPAD built-in function. */ - @Category(ParallelStatsDisabledTest.class) public class StringIT extends ParallelStatsDisabledIT { @@ -120,7 +119,7 @@ private void testLpad(Connection conn, List inputList, int length, List< @Test public void testCharPadding() throws Exception { ResultSet rs; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); conn.createStatement().execute("CREATE TABLE " + tableName + " (k CHAR(3) PRIMARY KEY)"); conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES('a')"); @@ -148,7 +147,7 @@ public void testCharPadding() throws Exception { @Test public void testBinaryPadding() throws Exception { ResultSet rs; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); conn.createStatement().execute("CREATE TABLE " + tableName + " (k BINARY(3) PRIMARY KEY)"); conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES('a')"); @@ -176,28 +175,28 @@ public void testBinaryPadding() throws Exception { @Test public void testNullInputStringSB() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); testLpad(conn, Lists.newArrayList("X", "X"), 4, Lists.newArrayList("", ""), "kv", Lists. newArrayList(null, null)); } @Test public void testEmptyFillExpr() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); testLpad(conn, Lists.newArrayList("ABCD", "ണഫɰɸ"), 6, Lists.newArrayList("", ""), Lists. newArrayList(null, null)); } @Test public void testDefaultFill() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); testLpad(conn, Lists.newArrayList("ABCD", "ണഫɰɸ"), 6, Lists. newArrayList(null, null), Lists.newArrayList(" ABCD", " ണഫɰɸ")); } @Test public void testLpadFillLengthGreaterThanPadLength() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); testLpad(conn, Lists.newArrayList("ABCD", "ണഫɰɸ", "ണഫɰɸ", "ABCD"), 8, Lists.newArrayList("123456", "ɚɚɦɚɚɦ", "123456", "ണഫɰɸണഫ"), Lists.newArrayList("1234ABCD", "ɚɚɦɚണഫɰɸ", "1234ണഫɰɸ", "ണഫɰɸABCD")); @@ -205,7 +204,7 @@ public void testLpadFillLengthGreaterThanPadLength() throws Exception { @Test public void testLpadFillLengthLessThanPadLength() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); testLpad(conn, Lists.newArrayList("ABCD", "ɰɸɰɸ", "ɰɸɰɸ", "ABCD"), 8, Lists.newArrayList("12", "ഫɰ", "12", "ഫɰ"), Lists.newArrayList("1212ABCD", "ഫɰഫɰɰɸɰɸ", "1212ɰɸɰɸ", "ഫɰഫɰABCD")); @@ -213,7 +212,7 @@ public void testLpadFillLengthLessThanPadLength() throws Exception { @Test public void testLpadFillLengthEqualPadLength() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); testLpad(conn, Lists.newArrayList("ABCD", "ɰɸɰɸ", "ɰɸɰɸ", "ABCD"), 8, Lists.newArrayList("1234", "ണഫɰɸ", "1234", "ണഫɰɸ"), Lists.newArrayList("1234ABCD", "ണഫɰɸɰɸɰɸ", "1234ɰɸɰɸ", "ണഫɰɸABCD")); @@ -221,35 +220,35 @@ public void testLpadFillLengthEqualPadLength() throws Exception { @Test public void testLpadZeroPadding() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ArrayList inputList = Lists.newArrayList("ABCD", "ണഫɰɸ", "ണഫɰɸ", "ABCD"); testLpad(conn, inputList, 4, Lists.newArrayList("1234", "ɚɦɚɦ", "1234", "ɚɦɚɦ"), inputList); } @Test public void testLpadTrucate() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); testLpad(conn, Lists.newArrayList("ABCD", "ണഫɰɸ", "ണഫɰɸ", "ABCD"), 2, Lists.newArrayList("12", "ɚɦ", "12", "ɚɦ"), Lists.newArrayList("AB", "ണഫ", "ണഫ", "AB")); } @Test public void testLpadZeroOutputStringLength() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); testLpad(conn, Lists.newArrayList("ABCD", "ണഫɰɸ", "ണഫɰɸ", "ABCD"), 0, Lists.newArrayList("12", "ɚɦ", "12", "ɚɦ"), Lists. newArrayList(null, null, null, null)); } @Test public void testNegativeOutputStringLength() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)); testLpad(conn, Lists.newArrayList("ABCD", "ണഫɰɸ", "ണഫɰɸ", "ABCD"), -1, Lists.newArrayList("12", "ɚɦ", "12", "ɚɦ"), Lists. newArrayList(null, null, null, null)); } @Test public void testStrConcat() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); conn.createStatement().execute("create table " + tableName + " (PK1 integer, F1 varchar, F2 varchar, F3 varchar, F4 varchar, constraint PK primary key (PK1))"); conn.createStatement().execute("upsert into " + tableName + "(PK1, F1,F3) values(0, 'tortilla', 'chip')"); @@ -264,7 +263,7 @@ public void testStrConcat() throws Exception { @Test public void testLpadWithNullArgs() throws Exception { ResultSet rs; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); conn.createStatement().execute("CREATE TABLE " + tableName + " (k CHAR(3) PRIMARY KEY, v1 VARCHAR, v2 INTEGER)"); conn.createStatement().execute("UPSERT INTO " + tableName + "(k) VALUES('a')"); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StringToArrayFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/StringToArrayFunctionIT.java index 5742928f230..214e882cab0 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/StringToArrayFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/StringToArrayFunctionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +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; @@ -28,10 +29,10 @@ import org.apache.phoenix.schema.types.PVarchar; import org.apache.phoenix.schema.types.PhoenixArray; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class StringToArrayFunctionIT extends ParallelStatsDisabledIT { @@ -40,7 +41,7 @@ public class StringToArrayFunctionIT extends ParallelStatsDisabledIT { @Before public void initTables() throws Exception { tableName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String ddl = "CREATE TABLE " + tableName + " (region_name VARCHAR PRIMARY KEY, string1 VARCHAR, string2 CHAR(50), delimiter1 VARCHAR, delimiter2 CHAR(20), nullstring1 VARCHAR, nullstring2 CHAR(20))"; conn.createStatement().execute(ddl); @@ -62,7 +63,7 @@ public void initTables() throws Exception { @Test public void testStringToArrayFunction1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery( @@ -78,7 +79,7 @@ public void testStringToArrayFunction1() throws Exception { @Test public void testStringToArrayFunction2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery( @@ -94,7 +95,7 @@ public void testStringToArrayFunction2() throws Exception { @Test public void testStringToArrayFunction3() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery( @@ -110,7 +111,7 @@ public void testStringToArrayFunction3() throws Exception { @Test public void testStringToArrayFunction4() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery( @@ -126,7 +127,7 @@ public void testStringToArrayFunction4() throws Exception { @Test public void testStringToArrayFunction5() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery( @@ -142,7 +143,7 @@ public void testStringToArrayFunction5() throws Exception { @Test public void testStringToArrayFunction6() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery( @@ -158,7 +159,7 @@ public void testStringToArrayFunction6() throws Exception { @Test public void testStringToArrayFunction7() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery( @@ -174,7 +175,7 @@ public void testStringToArrayFunction7() throws Exception { @Test public void testStringToArrayFunction8() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery( @@ -190,7 +191,7 @@ public void testStringToArrayFunction8() throws Exception { @Test public void testStringToArrayFunction9() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery( @@ -206,7 +207,7 @@ public void testStringToArrayFunction9() throws Exception { @Test public void testStringToArrayFunction10() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery( @@ -222,7 +223,7 @@ public void testStringToArrayFunction10() throws Exception { @Test public void testStringToArrayFunction11() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery( @@ -238,7 +239,7 @@ public void testStringToArrayFunction11() throws Exception { @Test public void testStringToArrayFunction12() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery( @@ -254,7 +255,7 @@ public void testStringToArrayFunction12() throws Exception { @Test public void testStringToArrayFunctionWithNestedFunctions1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery( @@ -268,7 +269,7 @@ public void testStringToArrayFunctionWithNestedFunctions1() throws Exception { @Test public void testStringToArrayFunctionWithNestedFunctions2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery( @@ -284,7 +285,7 @@ public void testStringToArrayFunctionWithNestedFunctions2() throws Exception { @Test public void testStringToArrayFunctionWithNestedFunctions3() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery( @@ -300,7 +301,7 @@ public void testStringToArrayFunctionWithNestedFunctions3() throws Exception { @Test public void testStringToArrayFunctionWithUpsert1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = @@ -325,7 +326,7 @@ public void testStringToArrayFunctionWithUpsert1() throws Exception { @Test public void testStringToArrayFunctionWithUpsert2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = @@ -350,7 +351,7 @@ public void testStringToArrayFunctionWithUpsert2() throws Exception { @Test public void testStringToArrayFunctionWithUpsertSelect1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String table1 = generateUniqueName(); String ddl = @@ -393,7 +394,7 @@ public void testStringToArrayFunctionWithUpsertSelect1() throws Exception { @Test public void testStringToArrayFunctionWithUpsertSelect2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String sourceTable = generateUniqueName(); @@ -439,7 +440,7 @@ public void testStringToArrayFunctionWithUpsertSelect2() throws Exception { @Test public void testStringToArrayFunctionInWhere1() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery("SELECT region_name FROM " + tableName @@ -452,7 +453,7 @@ public void testStringToArrayFunctionInWhere1() throws Exception { @Test public void testStringToArrayFunctionInWhere2() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery("SELECT region_name FROM " + tableName @@ -465,7 +466,7 @@ public void testStringToArrayFunctionInWhere2() throws Exception { @Test public void testStringToArrayFunctionInWhere3() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery("SELECT region_name FROM " + tableName diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SubBinaryFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SubBinaryFunctionIT.java index 8ba75c0064d..46fbc145954 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SubBinaryFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SubBinaryFunctionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.QueryUtil; import org.junit.Assert; import org.junit.Test; @@ -28,13 +29,14 @@ import java.sql.ResultSet; import java.sql.SQLException; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; @Category(ParallelStatsDisabledTest.class) public class SubBinaryFunctionIT extends ParallelStatsDisabledIT { @Test public void testBinary() throws Exception { String tableName = generateUniqueName(); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute("CREATE TABLE " + tableName + "(" + " id INTEGER NOT NULL,\n" + " BIN_PK BINARY(4) NOT NULL,\n" + @@ -98,7 +100,7 @@ public void testBinary() throws Exception { @Test public void testVarbinary() throws Exception { String tableName = generateUniqueName(); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute("CREATE TABLE " + tableName + "(" + " id INTEGER NOT NULL,\n" + " BIN_PK VARBINARY NOT NULL,\n" + @@ -163,7 +165,7 @@ public void testVarbinary() throws Exception { @Test public void testVarbinaryEncoded() throws Exception { String tableName = generateUniqueName(); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute("CREATE TABLE " + tableName + "(" + " id INTEGER NOT NULL,\n" + " BIN_PK VARBINARY_ENCODED NOT NULL,\n" + @@ -270,7 +272,7 @@ public void testVarbinaryEncoded() throws Exception { @Test public void testSubBinaryFunction() throws Exception { String tableName = generateUniqueName(); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute("CREATE TABLE " + tableName + "(" + " id INTEGER PRIMARY KEY,\n" + " VAR_BIN_COL VARBINARY,\n" + @@ -333,7 +335,7 @@ public void testSubBinaryFunction() throws Exception { @Test public void testExplainPlanWithSubBinaryFunctionInPK() throws Exception { String tableName = generateUniqueName(); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute("CREATE TABLE " + tableName + " (id INTEGER NOT NULL, VAR_BIN_COL VARBINARY NOT NULL, DESCRIPTION VARCHAR CONSTRAINT pk PRIMARY KEY (id, VAR_BIN_COL))"); conn.createStatement().execute("UPSERT INTO " + tableName + " VALUES (1, X'0102030405', 'desc1')"); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SumFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SumFunctionIT.java index b304e984f8f..e0a7568a907 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SumFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SumFunctionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -25,18 +26,17 @@ import java.sql.ResultSet; import java.sql.Statement; +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; - @Category(ParallelStatsDisabledTest.class) public class SumFunctionIT extends ParallelStatsDisabledIT { @Test public void testSumFunctionWithCaseWhenStatement() throws Exception { String tableName = generateUniqueName(); - - try (Connection c = DriverManager.getConnection(getUrl()); - Statement s = c.createStatement()) { + try (Connection c = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Statement s = c.createStatement()) { s.execute("create table " + tableName + " (id varchar primary key, col1 varchar, " + "col2 integer)"); s.execute("upsert into " + tableName + " values('id1', 'aaa', 2)"); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SyncUpdateCacheFreqIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SyncUpdateCacheFreqIT.java index 9604997a0d2..02ae156e17d 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SyncUpdateCacheFreqIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SyncUpdateCacheFreqIT.java @@ -18,6 +18,7 @@ package org.apache.phoenix.end2end; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.BaseTest; import org.apache.phoenix.thirdparty.com.google.common.collect.ImmutableList; import org.apache.phoenix.thirdparty.com.google.common.collect.ImmutableMap; @@ -42,9 +43,9 @@ import java.util.Random; import java.util.Set; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.util.UpgradeUtil.UPSERT_UPDATE_CACHE_FREQUENCY; import static org.junit.Assert.assertEquals; - //FIXME this class no @Category, and will not be run by maven public class SyncUpdateCacheFreqIT extends BaseTest { @@ -80,7 +81,11 @@ public class SyncUpdateCacheFreqIT extends BaseTest { @BeforeClass public static synchronized void doSetup() throws Exception { Map props = Maps.newHashMapWithExpectedSize(1); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } createBaseTable(SCHEMA_NAME, TABLE_NAME, true, TABLE_CACHE_FREQ); createIndex(getConnection(), SCHEMA_NAME, GLOBAL_INDEX, TABLE_NAME, VIEW_INDEX_COL, false); @@ -107,7 +112,7 @@ public void testSyncCacheFreqWithTenantView() throws Exception { false); } - try (PhoenixConnection conn = (PhoenixConnection) getConnection()) { + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) getConnection()) { PreparedStatement stmt = conn.prepareStatement(UPSERT_UPDATE_CACHE_FREQUENCY); @@ -132,7 +137,7 @@ public void testSyncCacheFreqWithTenantView() throws Exception { } // clear the server-side cache to get the latest built PTables - conn.unwrap(PhoenixConnection.class).getQueryServices().clearCache(); + conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().clearCache(); PhoenixConnection pcon = conn.unwrap(PhoenixConnection.class); pcon.setRunningUpgrade(true); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SystemCatalogRegionObserverIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SystemCatalogRegionObserverIT.java index 764c7e21673..f71c3109034 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SystemCatalogRegionObserverIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SystemCatalogRegionObserverIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.junit.Assert.assertTrue; import java.sql.Connection; @@ -31,6 +32,7 @@ import org.apache.phoenix.coprocessor.SystemCatalogRegionObserver; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.BaseTest; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; @@ -41,7 +43,6 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(NeedsOwnMiniClusterTest.class) public class SystemCatalogRegionObserverIT extends BaseTest { @@ -54,7 +55,11 @@ public static synchronized void doSetup() throws Exception { serverProps.put(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, "true"); Map clientProps = Maps.newHashMapWithExpectedSize(1); clientProps.put(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, "true"); - setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), new ReadOnlyProps(clientProps.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(serverProps.entrySet().iterator()),new ReadOnlyProps(clientProps.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), new ReadOnlyProps(clientProps.entrySet().iterator())); + } } protected Connection getConnection() throws SQLException{ @@ -66,7 +71,7 @@ protected Connection getConnection() throws SQLException{ @Test public void testSystemCatalogRegionObserverWasAdded() throws Exception { try (Connection conn = getConnection()){ - PhoenixConnection phoenixConn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection phoenixConn = conn.unwrap(PhoenixMonitoredConnection.class); Table syscatTable = phoenixConn.getQueryServices().getTable( SchemaUtil.getPhysicalTableName(PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME_BYTES, true).getName()); assertTrue("SystemCatalogRegionObserver was not added to SYSTEM.CATALOG", diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SystemCatalogRollbackEnabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SystemCatalogRollbackEnabledIT.java index fb2e379e594..9982dae4a55 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SystemCatalogRollbackEnabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SystemCatalogRollbackEnabledIT.java @@ -17,6 +17,8 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +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; @@ -42,6 +44,7 @@ import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.ColumnNotFoundException; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; import org.junit.BeforeClass; @@ -66,13 +69,17 @@ public static synchronized void doSetup() throws Exception { "true"); clientProps.put(QueryServices.ALLOW_SPLITTABLE_SYSTEM_CATALOG_ROLLBACK, "true"); - setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), - new ReadOnlyProps(clientProps.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(serverProps.entrySet().iterator()),new ReadOnlyProps(clientProps.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), + new ReadOnlyProps(clientProps.entrySet().iterator())); + } } private void createTableAndTenantViews(String tableName) throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); - Statement stmt = conn.createStatement();) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Statement stmt = conn.createStatement();) { stmt.execute("DROP TABLE IF EXISTS " + tableName); stmt.execute("CREATE TABLE " + tableName + " (TENANT_ID VARCHAR NOT NULL, " + @@ -94,7 +101,7 @@ private void createTableAndTenantViews(String tableName) throws Exception { private Connection getTenantConnection(String tenantId) throws SQLException { - Properties tenantProps = new Properties(); + Properties tenantProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); return DriverManager.getConnection(getUrl(), tenantProps); } @@ -144,7 +151,7 @@ public void testSystemCatalogDoesNotSplit() throws Exception { */ @Test public void testAddColumnOnParentFails() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final String parentTableName = SchemaUtil.getTableName( generateUniqueName(), generateUniqueName()); final String parentViewName = SchemaUtil.getTableName( @@ -195,7 +202,7 @@ public void testAddColumnOnParentFails() throws Exception { */ @Test public void testDropColumnOnParentFails() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final String parentTableName = SchemaUtil.getTableName( generateUniqueName(), generateUniqueName()); final String parentViewName = SchemaUtil.getTableName( @@ -249,7 +256,7 @@ public void testViewDoesNotSeeDataForDroppedColumn() throws Exception { generateUniqueName(), generateUniqueName()); final String viewName = "V_" + SchemaUtil.getTableName( generateUniqueName(), generateUniqueName()); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute("CREATE TABLE " + parentName + " (A INTEGER PRIMARY KEY, B INTEGER, C" + " VARCHAR, D INTEGER)"); @@ -263,7 +270,7 @@ public void testViewDoesNotSeeDataForDroppedColumn() throws Exception { conn.commit(); } - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { // Query from the parent table and assert expected values ResultSet rs = conn.createStatement().executeQuery( "SELECT A,B,C,D FROM " + parentName); @@ -287,7 +294,7 @@ public void testViewDoesNotSeeDataForDroppedColumn() throws Exception { assertFalse(rs.next()); } - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { // Drop a parent column from the view conn.createStatement().execute("ALTER VIEW " + viewName + " DROP COLUMN C"); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SystemTablesUpgradeIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SystemTablesUpgradeIT.java index 5153767f16a..8971a47674c 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SystemTablesUpgradeIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SystemTablesUpgradeIT.java @@ -17,6 +17,8 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -32,6 +34,7 @@ import org.apache.phoenix.coprocessorclient.MetaDataProtocol; import org.apache.phoenix.jdbc.ConnectionInfo; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; import org.apache.phoenix.jdbc.PhoenixTestDriver; import org.apache.phoenix.query.BaseTest; @@ -40,6 +43,7 @@ import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.query.QueryServicesTestImpl; import org.apache.phoenix.schema.SystemTaskSplitPolicy; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.junit.BeforeClass; import org.junit.Test; @@ -107,23 +111,27 @@ public synchronized ConnectionQueryServices getConnectionQueryServices(String ur public static synchronized void doSetup() throws Exception { Map props = Maps.newConcurrentMap(); props.put(BaseTest.DRIVER_CLASS_NAME_ATTRIB, PhoenixUpgradeCountingDriver.class.getName()); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @Test public void testUpgradeOnlyHappensOnce() throws Exception { - ConnectionQueryServices services = DriverManager.getConnection(getUrl()).unwrap(PhoenixConnection.class).getQueryServices(); + ConnectionQueryServices services = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixMonitoredConnection.class).getQueryServices(); assertTrue(services instanceof PhoenixUpgradeCountingServices); // Check if the timestamp version is changing between the current version and prior version boolean wasTimestampChanged = systemTableVersion != MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP; reinitialize = true; systemTableVersion = MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP; - DriverManager.getConnection(getUrl()); + DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).close(); // Confirm that if the timestamp changed, that an upgrade was performed (and that if it // didn't, that an upgrade wasn't attempted). assertEquals(wasTimestampChanged ? 1 : 0, countUpgradeAttempts); // Confirm that another connection does not increase the number of times upgrade was attempted - DriverManager.getConnection(getUrl()); + DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).close(); assertEquals(wasTimestampChanged ? 1 : 0, countUpgradeAttempts); // Additional test for PHOENIX-6125 // Confirm that SYSTEM.TASK has split policy set as diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TTLAsPhoenixTTLIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TTLAsPhoenixTTLIT.java index 9b270093ed5..37ffdd65df0 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TTLAsPhoenixTTLIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TTLAsPhoenixTTLIT.java @@ -26,6 +26,7 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.schema.ColumnNotFoundException; import org.apache.phoenix.schema.ColumnFamilyNotFoundException; import org.apache.phoenix.schema.LiteralTTLExpression; @@ -36,6 +37,7 @@ import org.apache.phoenix.schema.TTLExpressionFactory; import org.apache.phoenix.util.ByteUtil; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.TestUtil; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -59,12 +61,12 @@ import static org.apache.phoenix.schema.LiteralTTLExpression.TTL_EXPRESSION_FOREVER; import static org.apache.phoenix.schema.LiteralTTLExpression.TTL_EXPRESSION_NOT_DEFINED; import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB; +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.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; - @Category(ParallelStatsDisabledTest.class) @RunWith(Parameterized.class) public class TTLAsPhoenixTTLIT extends ParallelStatsDisabledIT{ @@ -122,8 +124,8 @@ public static synchronized Collection data() { */ @Test public void testCreateTableWithTTL() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl());) { - PTable table = conn.unwrap(PhoenixConnection.class).getTable(new PTableKey(null, + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { + PTable table = conn.unwrap(PhoenixMonitoredConnection.class).getTable(new PTableKey(null, createTableWithOrWithOutTTLAsItsProperty(conn, true))); TestUtil.assertTTLValue(conn, table, defaultTTL); assertTrue("RowKeyMatcher should be Null", @@ -133,8 +135,8 @@ public void testCreateTableWithTTL() throws Exception { @Test public void testCreateTableWithNoTTL() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl());) { - PTable table = conn.unwrap(PhoenixConnection.class).getTable(new PTableKey(null, + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { + PTable table = conn.unwrap(PhoenixMonitoredConnection.class).getTable(new PTableKey(null, createTableWithOrWithOutTTLAsItsProperty(conn, false))); TestUtil.assertTTLValue(conn, table, TTL_EXPRESSION_NOT_DEFINED); assertFalse(table.hasConditionalTTL()); @@ -143,9 +145,9 @@ public void testCreateTableWithNoTTL() throws Exception { @Test public void testSwitchingTTLFromCondToValue() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tableName = createTableWithOrWithOutTTLAsItsProperty(conn, true); - PTable table = conn.unwrap(PhoenixConnection.class). + PTable table = conn.unwrap(PhoenixMonitoredConnection.class). getTable(new PTableKey(null, tableName)); TestUtil.assertTTLValue(conn, table, defaultTTL); assertTrue(table.hasConditionalTTL() == useExpression); @@ -157,7 +159,7 @@ public void testSwitchingTTLFromCondToValue() throws Exception { TTLExpression expected = useExpression ? TTLExpressionFactory.create(DEFAULT_TTL_FOR_ALTER) : TTLExpressionFactory.create(DEFAULT_TTL_EXPRESSION_FOR_ALTER); - TestUtil.assertTTLValue(conn.unwrap(PhoenixConnection.class), expected, tableName); + TestUtil.assertTTLValue(conn.unwrap(PhoenixMonitoredConnection.class), expected, tableName); } } @@ -177,12 +179,12 @@ public void testCreateTableWithTTLWithDifferentColumnFamilies() throws Excepti + " col1 integer NOT NULL," + " b.col2 bigint," + " col3 bigint, " + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1)" + " ) TTL=" + DEFAULT_TTL_FOR_TEST; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); TTLExpression expected = TTLExpressionFactory.create(DEFAULT_TTL_FOR_TEST); - TestUtil.assertTTLValue(conn.unwrap(PhoenixConnection.class), expected, tableName); + TestUtil.assertTTLValue(conn.unwrap(PhoenixMonitoredConnection.class), expected, tableName); //Setting TTL should also stored in CF Descriptor properties for Backward compatibility - Admin admin = driver.getConnectionQueryServices(getUrl(), new Properties()).getAdmin(); + Admin admin = driver.getConnectionQueryServices(getActiveUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).getAdmin(); ColumnFamilyDescriptor[] columnFamilies = admin.getDescriptor(TableName.valueOf(tableName)).getColumnFamilies(); assertEquals(DEFAULT_TTL_FOR_TEST, columnFamilies[0].getTimeToLive()); @@ -199,18 +201,18 @@ public void testCreateAndAlterTableDDLWithForeverAndNoneTTLValues() throws Excep + " col1 integer NOT NULL," + " b.col2 bigint," + " col3 bigint, " + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1)" + " ) TTL=FOREVER"; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute(ddl); - TestUtil.assertTTLValue(conn.unwrap(PhoenixConnection.class), + TestUtil.assertTTLValue(conn.unwrap(PhoenixMonitoredConnection.class), TTL_EXPRESSION_NOT_DEFINED, tableName); ddl = "ALTER TABLE " + tableName + " SET TTL=NONE"; conn.createStatement().execute(ddl); - TestUtil.assertTTLValue(conn.unwrap(PhoenixConnection.class), + TestUtil.assertTTLValue(conn.unwrap(PhoenixMonitoredConnection.class), TTL_EXPRESSION_NOT_DEFINED, tableName); //Setting TTL should not be stored as CF Descriptor properties when //phoenix.table.ttl.enabled is true - Admin admin = driver.getConnectionQueryServices(getUrl(), new Properties()).getAdmin(); + Admin admin = driver.getConnectionQueryServices(getActiveUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).getAdmin(); ColumnFamilyDescriptor[] columnFamilies = admin.getDescriptor(TableName.valueOf(tableName)).getColumnFamilies(); assertEquals(HConstants.FOREVER, columnFamilies[0].getTimeToLive()); @@ -222,12 +224,12 @@ public void testCreateAndAlterTableDDLWithForeverAndNoneTTLValues() throws Excep + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1)" + " ) TTL=NONE"; conn.createStatement().execute(ddl); - TestUtil.assertTTLValue(conn.unwrap(PhoenixConnection.class), + TestUtil.assertTTLValue(conn.unwrap(PhoenixMonitoredConnection.class), TTL_EXPRESSION_NOT_DEFINED, tableName); ddl = "ALTER TABLE " + tableName + " SET TTL=FOREVER"; conn.createStatement().execute(ddl); - TestUtil.assertTTLValue(conn.unwrap(PhoenixConnection.class), + TestUtil.assertTTLValue(conn.unwrap(PhoenixMonitoredConnection.class), TTL_EXPRESSION_NOT_DEFINED, tableName); //Setting TTL should not be stored as CF Descriptor properties when //phoenix.table.ttl.enabled is true @@ -239,28 +241,28 @@ public void testCreateAndAlterTableDDLWithForeverAndNoneTTLValues() throws Excep @Test public void testSettingTTLAsAlterTableCommand() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl(), new Properties()); - PhoenixConnection pConn = conn.unwrap(PhoenixConnection.class);){ + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + PhoenixMonitoredConnection pConn = conn.unwrap(PhoenixMonitoredConnection.class);){ String tableName = createTableWithOrWithOutTTLAsItsProperty(conn, false); //Checking Default TTL in case of PhoenixTTLEnabled - TestUtil.assertTTLValue(conn.unwrap(PhoenixConnection.class), TTL_EXPRESSION_NOT_DEFINED, tableName); + TestUtil.assertTTLValue(conn.unwrap(PhoenixMonitoredConnection.class), TTL_EXPRESSION_NOT_DEFINED, tableName); String ddl = "ALTER TABLE " + tableName + " SET TTL = " + this.alterTTLDDLOption; conn.createStatement().execute(ddl); - TestUtil.assertTTLValue(conn.unwrap(PhoenixConnection.class), this.alterTTL, tableName); + TestUtil.assertTTLValue(conn.unwrap(PhoenixMonitoredConnection.class), this.alterTTL, tableName); //Asserting TTL should not be stored as CF Descriptor properties when //phoenix.table.ttl.enabled is true - Admin admin = driver.getConnectionQueryServices(getUrl(), new Properties()).getAdmin(); + Admin admin = driver.getConnectionQueryServices(getActiveUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).getAdmin(); ColumnFamilyDescriptor[] columnFamilies = admin.getDescriptor(TableName.valueOf(tableName)).getColumnFamilies(); PTable pTable = pConn.getTableNoCache(tableName); - TestUtil.assertTTLValue(conn.unwrap(PhoenixConnection.class), this.alterTTL, tableName); + TestUtil.assertTTLValue(conn.unwrap(PhoenixMonitoredConnection.class), this.alterTTL, tableName); } } @Test public void testSettingTTLForIndexes() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tableName = createTableWithOrWithOutTTLAsItsProperty(conn, true); //By default, Indexes should set TTL what Base Table has @@ -275,7 +277,7 @@ public void testSettingTTLForIndexes() throws Exception { String localIndexName = createIndexOnTableOrViewProvidedWithTTL(conn, tableName, PTable.IndexType.LOCAL, false); String globalIndexName = createIndexOnTableOrViewProvidedWithTTL(conn, tableName, PTable.IndexType.GLOBAL, false); - indexes = conn.unwrap(PhoenixConnection.class).getTable(new PTableKey(null, tableName)).getIndexes(); + indexes = conn.unwrap(PhoenixMonitoredConnection.class).getTable(new PTableKey(null, tableName)).getIndexes(); for (PTable index : indexes) { TestUtil.assertTTLValue(conn, index, TTL_EXPRESSION_NOT_DEFINED); assertTrue(Bytes.compareTo( @@ -326,7 +328,7 @@ public void testConditionalTTLDDL() throws Exception { if (!useExpression) { return; } - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tableName = generateUniqueName(); String ddl = "CREATE TABLE %s (ID1 VARCHAR NOT NULL, ID2 INTEGER NOT NULL, COL1 VARCHAR, COL2 DATE " + "CONSTRAINT PK PRIMARY KEY(ID1, ID2)) TTL = '%s'"; @@ -339,10 +341,10 @@ public void testConditionalTTLDDL() throws Exception { String ttl = "ID2 = 34 AND COL2 > CURRENT_DATE() + 1000"; conn.createStatement().execute(String.format(ddl, tableName, ttl)); TTLExpression expected = TTLExpressionFactory.create(ttl); - TestUtil.assertTTLValue(conn.unwrap(PhoenixConnection.class), expected, tableName); + TestUtil.assertTTLValue(conn.unwrap(PhoenixMonitoredConnection.class), expected, tableName); conn.createStatement().execute(String.format("ALTER TABLE %s SET TTL=NONE", tableName)); - TestUtil.assertTTLValue(conn.unwrap(PhoenixConnection.class), TTL_EXPRESSION_NOT_DEFINED, tableName); + TestUtil.assertTTLValue(conn.unwrap(PhoenixMonitoredConnection.class), TTL_EXPRESSION_NOT_DEFINED, tableName); try { conn.createStatement().execute(String.format("ALTER TABLE %s SET TTL='%s'", @@ -365,32 +367,32 @@ public void testConditionalTTLDDL() throws Exception { ttl = "COL2 > CURRENT_DATE() + 200 AND VINT > 123"; conn.createStatement().execute(String.format(ddl, viewName, tableName, ttl)); expected = TTLExpressionFactory.create(ttl); - TestUtil.assertTTLValue(conn.unwrap(PhoenixConnection.class), expected, viewName); + TestUtil.assertTTLValue(conn.unwrap(PhoenixMonitoredConnection.class), expected, viewName); ttl = "COL2 > CURRENT_DATE() + 500 AND VINT > 123"; conn.createStatement().execute(String.format("ALTER VIEW %s SET TTL='%s'", viewName, ttl)); expected = TTLExpressionFactory.create(ttl); - TestUtil.assertTTLValue(conn.unwrap(PhoenixConnection.class), expected, viewName); + TestUtil.assertTTLValue(conn.unwrap(PhoenixMonitoredConnection.class), expected, viewName); } } @Test public void testSettingTTLForViewsOnTableWithTTL() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tenantID = generateUniqueName().substring(1); String tenantID1 = generateUniqueName().substring(1); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(TENANT_ID_ATTRIB, tenantID); Connection tenantConn = DriverManager.getConnection(getUrl(), props); - Properties props1 = new Properties(); + Properties props1 = PropertiesUtil.deepCopy(TEST_PROPERTIES); props1.setProperty(TENANT_ID_ATTRIB, tenantID1); Connection tenantConn1 = DriverManager.getConnection(getUrl(), props1); String tableName = createTableWithOrWithOutTTLAsItsProperty(conn, true); - TestUtil.assertTTLValue(conn.unwrap(PhoenixConnection.class), defaultTTL, tableName); + TestUtil.assertTTLValue(conn.unwrap(PhoenixMonitoredConnection.class), defaultTTL, tableName); //Setting TTL on views is not allowed if Table already has TTL try { @@ -412,14 +414,14 @@ public void testSettingTTLForViewsOnTableWithTTL() throws Exception { //View should have gotten TTL from parent table. String viewName = createUpdatableViewOnTableWithTTL(conn, tableName, false); - TestUtil.assertTTLValue(conn.unwrap(PhoenixConnection.class), defaultTTL, viewName); + TestUtil.assertTTLValue(conn.unwrap(PhoenixMonitoredConnection.class), defaultTTL, viewName); //Child View's PTable gets TTL from parent View's PTable which gets from Table. String childView = createViewOnViewWithTTL(tenantConn, viewName, false); - TestUtil.assertTTLValue(tenantConn.unwrap(PhoenixConnection.class), defaultTTL, childView); + TestUtil.assertTTLValue(tenantConn.unwrap(PhoenixMonitoredConnection.class), defaultTTL, childView); String childView1 = createViewOnViewWithTTL(tenantConn1, viewName, false); - TestUtil.assertTTLValue(tenantConn1.unwrap(PhoenixConnection.class), defaultTTL, childView1); + TestUtil.assertTTLValue(tenantConn1.unwrap(PhoenixMonitoredConnection.class), defaultTTL, childView1); createIndexOnTableOrViewProvidedWithTTL(conn, viewName, PTable.IndexType.GLOBAL, false); @@ -427,7 +429,7 @@ public void testSettingTTLForViewsOnTableWithTTL() throws Exception { false); List indexes = PhoenixRuntime.getTable( - conn.unwrap(PhoenixConnection.class), viewName).getIndexes(); + conn.unwrap(PhoenixMonitoredConnection.class), viewName).getIndexes(); for (PTable index : indexes) { TestUtil.assertTTLValue(conn, index, defaultTTL); @@ -435,7 +437,7 @@ public void testSettingTTLForViewsOnTableWithTTL() throws Exception { createIndexOnTableOrViewProvidedWithTTL(conn, tableName, PTable.IndexType.GLOBAL, false); List tIndexes = PhoenixRuntime.getTable( - conn.unwrap(PhoenixConnection.class), tableName).getIndexes(); + conn.unwrap(PhoenixMonitoredConnection.class), tableName).getIndexes(); for (PTable index : tIndexes) { TestUtil.assertTTLValue(conn, index, defaultTTL); @@ -445,15 +447,15 @@ public void testSettingTTLForViewsOnTableWithTTL() throws Exception { @Test public void testAlteringTTLToNONEAndThenSettingAtAnotherLevel() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tenantID = generateUniqueName().substring(1); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(TENANT_ID_ATTRIB, tenantID); Connection tenantConn = DriverManager.getConnection(getUrl(), props); String tableName = createTableWithOrWithOutTTLAsItsProperty(conn, true); - TestUtil.assertTTLValue(conn.unwrap(PhoenixConnection.class), defaultTTL, tableName); + TestUtil.assertTTLValue(conn.unwrap(PhoenixMonitoredConnection.class), defaultTTL, tableName); //Setting TTL on views is not allowed if Table already has TTL try { @@ -467,14 +469,14 @@ public void testAlteringTTLToNONEAndThenSettingAtAnotherLevel() throws Exception String ddl = "ALTER TABLE " + tableName + " SET TTL=NONE"; conn.createStatement().execute(ddl); - TestUtil.assertTTLValue(conn.unwrap(PhoenixConnection.class), + TestUtil.assertTTLValue(conn.unwrap(PhoenixMonitoredConnection.class), TTL_EXPRESSION_NOT_DEFINED, tableName); String viewName = createUpdatableViewOnTableWithTTL(conn, tableName, true); TTLExpression expectedChildTTl = useExpression ? TTLExpressionFactory.create(DEFAULT_TTL_EXPRESSION) : TTLExpressionFactory.create(DEFAULT_TTL_FOR_CHILD); - TestUtil.assertTTLValue(conn.unwrap(PhoenixConnection.class), expectedChildTTl, viewName); + TestUtil.assertTTLValue(conn.unwrap(PhoenixMonitoredConnection.class), expectedChildTTl, viewName); try { createViewOnViewWithTTL(tenantConn, viewName, true); @@ -499,12 +501,12 @@ public void testAlteringTTLToNONEAndThenSettingAtAnotherLevel() throws Exception conn.createStatement().execute(ddl); String childView = createViewOnViewWithTTL(tenantConn, viewName, true); - TestUtil.assertTTLValue(tenantConn.unwrap(PhoenixConnection.class), expectedChildTTl, childView); + TestUtil.assertTTLValue(tenantConn.unwrap(PhoenixMonitoredConnection.class), expectedChildTTl, childView); ddl = "ALTER VIEW " + childView + " SET TTL=NONE"; tenantConn.createStatement().execute(ddl); - TestUtil.assertTTLValue(tenantConn.unwrap(PhoenixConnection.class), + TestUtil.assertTTLValue(tenantConn.unwrap(PhoenixMonitoredConnection.class), TTL_EXPRESSION_NOT_DEFINED, childView); ddl = "ALTER VIEW " + viewName + " SET TTL=" + ttlAlter; @@ -512,37 +514,37 @@ public void testAlteringTTLToNONEAndThenSettingAtAnotherLevel() throws Exception TTLExpression expectedAlterTTl = useExpression ? TTLExpressionFactory.create(DEFAULT_TTL_EXPRESSION_FOR_ALTER) : TTLExpressionFactory.create(DEFAULT_TTL_FOR_ALTER); - TestUtil.assertTTLValue(conn.unwrap(PhoenixConnection.class), expectedAlterTTl, viewName); + TestUtil.assertTTLValue(conn.unwrap(PhoenixMonitoredConnection.class), expectedAlterTTl, viewName); } } @Test public void testAlteringTTLAtOneLevelAndCheckingAtAnotherLevel() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tenantID = generateUniqueName().substring(1); String tenantID1 = generateUniqueName().substring(1); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(TENANT_ID_ATTRIB, tenantID); Connection tenantConn = DriverManager.getConnection(getUrl(), props); - Properties props1 = new Properties(); + Properties props1 = PropertiesUtil.deepCopy(TEST_PROPERTIES); props1.setProperty(TENANT_ID_ATTRIB, tenantID1); Connection tenantConn1 = DriverManager.getConnection(getUrl(), props1); String tableName = createTableWithOrWithOutTTLAsItsProperty(conn, true); - TestUtil.assertTTLValue(conn.unwrap(PhoenixConnection.class), defaultTTL, tableName); + TestUtil.assertTTLValue(conn.unwrap(PhoenixMonitoredConnection.class), defaultTTL, tableName); //View should have gotten TTL from parent table. String viewName = createUpdatableViewOnTableWithTTL(conn, tableName, false); - TestUtil.assertTTLValue(conn.unwrap(PhoenixConnection.class), defaultTTL, viewName); + TestUtil.assertTTLValue(conn.unwrap(PhoenixMonitoredConnection.class), defaultTTL, viewName); //Child View's PTable gets TTL from parent View's PTable which gets from Table. String childView = createViewOnViewWithTTL(tenantConn, viewName, false); - TestUtil.assertTTLValue(tenantConn.unwrap(PhoenixConnection.class), defaultTTL, childView); + TestUtil.assertTTLValue(tenantConn.unwrap(PhoenixMonitoredConnection.class), defaultTTL, childView); String childView1 = createViewOnViewWithTTL(tenantConn1, viewName, false); - TestUtil.assertTTLValue(tenantConn1.unwrap(PhoenixConnection.class), defaultTTL, childView1); + TestUtil.assertTTLValue(tenantConn1.unwrap(PhoenixMonitoredConnection.class), defaultTTL, childView1); String ttlAlter = (useExpression ? String.format("'%s'", DEFAULT_TTL_EXPRESSION_FOR_ALTER) : @@ -560,9 +562,9 @@ public void testAlteringTTLAtOneLevelAndCheckingAtAnotherLevel() throws Exceptio TTLExpressionFactory.create(DEFAULT_TTL_EXPRESSION_FOR_ALTER) : TTLExpressionFactory.create(DEFAULT_TTL_FOR_ALTER); //Assert TTL for each entity again with altered value - TestUtil.assertTTLValue(conn.unwrap(PhoenixConnection.class), expectedAlterTTl, viewName); - TestUtil.assertTTLValue(tenantConn.unwrap(PhoenixConnection.class), expectedAlterTTl, childView); - TestUtil.assertTTLValue(tenantConn1.unwrap(PhoenixConnection.class), expectedAlterTTl, childView1); + TestUtil.assertTTLValue(conn.unwrap(PhoenixMonitoredConnection.class), expectedAlterTTl, viewName); + TestUtil.assertTTLValue(tenantConn.unwrap(PhoenixMonitoredConnection.class), expectedAlterTTl, childView); + TestUtil.assertTTLValue(tenantConn1.unwrap(PhoenixMonitoredConnection.class), expectedAlterTTl, childView1); } } @@ -649,12 +651,12 @@ private String createViewOnViewWithTTL(Connection conn, String parentViewName, public static void clearCache(Connection tenantConnection, String schemaName, String tableName) throws SQLException { - PhoenixConnection currentConnection = tenantConnection.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection currentConnection = tenantConnection.unwrap(PhoenixMonitoredConnection.class); PName tenantIdName = currentConnection.getTenantId(); String tenantId = tenantIdName == null ? "" : tenantIdName.getString(); // Clear server side cache - currentConnection.unwrap(PhoenixConnection.class).getQueryServices().clearTableFromCache( + currentConnection.unwrap(PhoenixMonitoredConnection.class).getQueryServices().clearTableFromCache( Bytes.toBytes(tenantId), schemaName == null ? ByteUtil.EMPTY_BYTE_ARRAY : Bytes.toBytes(schemaName), Bytes.toBytes(tableName), 0); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TTLIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TTLIT.java index 2fe58d13939..6dfec86eeb3 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TTLIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TTLIT.java @@ -20,6 +20,7 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.PhoenixTestBuilder; import org.apache.phoenix.query.PhoenixTestBuilder.SchemaBuilder; import org.apache.phoenix.query.PhoenixTestBuilder.SchemaBuilder.TableOptions; @@ -28,6 +29,7 @@ import org.apache.phoenix.schema.TTLExpression; import org.apache.phoenix.thirdparty.com.google.common.collect.Lists; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.TestUtil; import org.junit.Assert; import org.junit.Test; @@ -45,7 +47,7 @@ import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TTL_NOT_DEFINED; import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB; - +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; @Category(ParallelStatsDisabledTest.class) @RunWith(Parameterized.class) public class TTLIT extends ParallelStatsDisabledIT { @@ -183,8 +185,7 @@ public void testTTLAtTableLevelWithIndex() throws Exception { PTable table = schemaBuilder.getBaseTable(); String indexName = schemaBuilder.getEntityTableIndexName(); - - try (Connection globalConnection = DriverManager.getConnection(getUrl())) { + try (Connection globalConnection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { assertTTLForGivenPTable(globalConnection, table, DEFAULT_TEST_TTL_VALUE); assertTTLForIndexName(globalConnection, indexName, DEFAULT_TEST_TTL_VALUE); //Assert TTL for index by getting PTable from table's PTable @@ -228,10 +229,9 @@ public void testTTLInHierarchyDefinedAtTableLevel() throws Exception { PTable table = schemaBuilder.getBaseTable(); String globalView = schemaBuilder.getEntityGlobalViewName(); String childView = schemaBuilder.getEntityTenantViewName(); - - try (Connection globalConnection = DriverManager.getConnection(getUrl()); + try (Connection globalConnection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenantConnection = DriverManager.getConnection( - getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId())) { + getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { //All level entities should have TTL value equal to TTL defined at table level assertTTLForGivenPTable(globalConnection, table, DEFAULT_TEST_TTL_VALUE); assertTTLForGivenEntity(globalConnection, globalView, DEFAULT_TEST_TTL_VALUE); @@ -273,10 +273,9 @@ public void testAlteringTTLForViewsInHierarchyWithTTLAtTableLevel() throws Excep PTable table = schemaBuilder.getBaseTable(); String globalViewName = schemaBuilder.getEntityGlobalViewName(); String childViewName = schemaBuilder.getEntityTenantViewName(); - - try (Connection globalConnection = DriverManager.getConnection(getUrl()); + try (Connection globalConnection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenantConnection = DriverManager.getConnection( - getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId())) { + getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { //All level entities should have TTL value equal to TTL defined at table level assertTTLForGivenPTable(globalConnection, table, DEFAULT_TEST_TTL_VALUE); assertTTLForGivenEntity(globalConnection, globalViewName, DEFAULT_TEST_TTL_VALUE); @@ -321,10 +320,9 @@ public void testTTLInHierarchyDefinedAtTableLevelWithIndex() throws Exception { String indexName = schemaBuilder.getEntityTableIndexName(); String globalView = schemaBuilder.getEntityGlobalViewName(); String childView = schemaBuilder.getEntityTenantViewName(); - - try (Connection globalConnection = DriverManager.getConnection(getUrl()); + try (Connection globalConnection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenantConnection = DriverManager.getConnection( - getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId())) { + getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { //All level entities should have TTL value equal to TTL defined at table level assertTTLForGivenPTable(globalConnection, table, DEFAULT_TEST_TTL_VALUE); assertTTLForIndexName(globalConnection, indexName, DEFAULT_TEST_TTL_VALUE); @@ -352,9 +350,9 @@ public void testTTLInHierarchyDefinedAtTableLevelWithIndexAtGlobalLevel() throws String childView = schemaBuilder.getEntityTenantViewName(); - try (Connection globalConnection = DriverManager.getConnection(getUrl()); + try (Connection globalConnection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenantConnection = DriverManager.getConnection( - getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId())) { + getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { //All level entities should have TTL value equal to TTL defined at table level assertTTLForGivenPTable(globalConnection, table, DEFAULT_TEST_TTL_VALUE); @@ -381,9 +379,9 @@ public void testTTLInHierarchyDefinedAtTableLevelWithIndexAtTenantLevel() throws String childView = schemaBuilder.getEntityTenantViewName(); String childViewIndexName = isMultiTenant ? schemaBuilder.getEntityTenantViewIndexName() : SKIP_ASSERT; - try (Connection globalConnection = DriverManager.getConnection(getUrl()); + try (Connection globalConnection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenantConnection = DriverManager.getConnection( - getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId())) { + getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { //All level entities should have TTL value equal to TTL defined at table level assertTTLForGivenPTable(globalConnection, table, DEFAULT_TEST_TTL_VALUE); @@ -411,9 +409,9 @@ public void testTTLHierarchyDefinedAtGlobalViewLevel() throws Exception { String globalViewIndexName = schemaBuilder.getEntityGlobalViewIndexName(); String childViewName = schemaBuilder.getEntityTenantViewName(); - try (Connection globalConnection = DriverManager.getConnection(getUrl()); + try (Connection globalConnection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenantConnection = DriverManager.getConnection( - getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId())) { + getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { //All level entities should have TTL value equal to TTL defined at table level assertTTLForGivenPTable(globalConnection, table, TTL_NOT_DEFINED); assertTTLForGivenEntity(globalConnection, globalViewName, DEFAULT_TEST_TTL_VALUE_AT_GLOBAL); @@ -434,9 +432,9 @@ public void testTTLHierarchyDefinedAtGlobalViewLevelWithTenantIndex() throws Exc String childViewName = schemaBuilder.getEntityTenantViewName(); String childViewIndexName = isMultiTenant ? schemaBuilder.getEntityTenantViewIndexName() : SKIP_ASSERT; - try (Connection globalConnection = DriverManager.getConnection(getUrl()); + try (Connection globalConnection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenantConnection = DriverManager.getConnection( - getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId())) { + getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { //All level entities should have TTL value equal to TTL defined at table level assertTTLForGivenPTable(globalConnection, table, TTL_NOT_DEFINED); assertTTLForGivenEntity(globalConnection, globalViewName, DEFAULT_TEST_TTL_VALUE_AT_GLOBAL); @@ -465,9 +463,9 @@ public void testSettingTTLAtTenantViewLevelWithTTLDefinedAtGlobalView() throws E String globalViewName = schemaBuilder.getEntityGlobalViewName(); String childViewName = schemaBuilder.getEntityTenantViewName(); - try (Connection globalConnection = DriverManager.getConnection(getUrl()); + try (Connection globalConnection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenantConnection = DriverManager.getConnection( - getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId())) { + getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { //All level entities should have TTL value equal to TTL defined at table level assertTTLForGivenPTable(globalConnection, table, TTL_NOT_DEFINED); @@ -488,9 +486,9 @@ public void testAlteringTTLAtDifferentLevelsWithTTLDefinedAtGlobalView() throws String globalViewName = schemaBuilder.getEntityGlobalViewName(); String childViewName = schemaBuilder.getEntityTenantViewName(); - try (Connection globalConnection = DriverManager.getConnection(getUrl()); + try (Connection globalConnection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenantConnection = DriverManager.getConnection( - getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId())) { + getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { //All level entities should have TTL value equal to TTL defined at table level assertTTLForGivenPTable(globalConnection, table, TTL_NOT_DEFINED); assertTTLForGivenEntity(globalConnection, globalViewName, DEFAULT_TEST_TTL_VALUE_AT_GLOBAL); @@ -529,9 +527,9 @@ public void testTTLHierarchyDefinedAtTenantViewLevel() throws Exception { String childView = schemaBuilder.getEntityTenantViewName(); String childViewIndex = isMultiTenant ? schemaBuilder.getEntityTenantViewIndexName() : SKIP_ASSERT; - try (Connection globalConnection = DriverManager.getConnection(getUrl()); + try (Connection globalConnection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenantConnection = DriverManager.getConnection( - getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId())) { + getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { //All level entities should have TTL value equal to TTL defined at table level assertTTLForGivenPTable(globalConnection, table, TTL_NOT_DEFINED); assertTTLForGivenEntity(globalConnection, globalView, TTL_NOT_DEFINED); @@ -552,9 +550,9 @@ public void testSettingAndAlteringTTLInHierarchyAboveOfTenantViewWithTTLDefined( String childView = schemaBuilder.getEntityTenantViewName(); String childViewIndex = isMultiTenant ? schemaBuilder.getEntityTenantViewIndexName() : SKIP_ASSERT; - try (Connection globalConnection = DriverManager.getConnection(getUrl()); + try (Connection globalConnection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenantConnection = DriverManager.getConnection( - getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId())) { + getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { //All level entities should have TTL value equal to TTL defined at table level assertTTLForGivenPTable(globalConnection, table, TTL_NOT_DEFINED); assertTTLForGivenEntity(globalConnection, globalView, TTL_NOT_DEFINED); @@ -600,9 +598,9 @@ public void testAlteringTTLFromTableToLevel1() throws Exception { String tenantViewName = schemaBuilder.getEntityTenantViewName(); String tenantViewIndexName = isMultiTenant ? schemaBuilder.getEntityTenantViewIndexName() : SKIP_ASSERT; - try (Connection globalConnection = DriverManager.getConnection(getUrl()); + try (Connection globalConnection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenantConnection = DriverManager.getConnection( - getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId())) { + getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { //All level entities should have TTL value equal to TTL defined at table level assertTTLForGivenPTable(globalConnection, table, DEFAULT_TEST_TTL_VALUE); assertTTLForGivenEntity(globalConnection, globalViewName, DEFAULT_TEST_TTL_VALUE); @@ -615,7 +613,7 @@ public void testAlteringTTLFromTableToLevel1() throws Exception { globalConnection.createStatement().execute(dml); //Clearing cache as MetaDataCaching is not there for TTL usecase - globalConnection.unwrap(PhoenixConnection.class).getQueryServices().clearCache(); + globalConnection.unwrap(PhoenixMonitoredConnection.class).getQueryServices().clearCache(); assertTTLForGivenEntity(globalConnection, tableName, TTL_NOT_DEFINED); assertTTLForGivenEntity(globalConnection, globalViewName, TTL_NOT_DEFINED); @@ -628,7 +626,7 @@ public void testAlteringTTLFromTableToLevel1() throws Exception { globalConnection.createStatement().execute(dml); //Clearing cache again - globalConnection.unwrap(PhoenixConnection.class).getQueryServices().clearCache(); + globalConnection.unwrap(PhoenixMonitoredConnection.class).getQueryServices().clearCache(); assertTTLForGivenEntity(globalConnection, tableName, TTL_NOT_DEFINED); assertTTLForGivenEntity(globalConnection, globalViewName, ALTER_TEST_TTL_VALUE); @@ -654,9 +652,9 @@ public void testAlteringTTLFromTableToLevel2() throws Exception { String tenantViewName = schemaBuilder.getEntityTenantViewName(); String tenantViewIndexName = isMultiTenant ? schemaBuilder.getEntityTenantViewIndexName() : SKIP_ASSERT; - try (Connection globalConnection = DriverManager.getConnection(getUrl()); + try (Connection globalConnection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenantConnection = DriverManager.getConnection( - getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId())) { + getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { //All level entities should have TTL value equal to TTL defined at table level assertTTLForGivenPTable(globalConnection, table, DEFAULT_TEST_TTL_VALUE); assertTTLForGivenEntity(globalConnection, globalViewName, DEFAULT_TEST_TTL_VALUE); @@ -669,7 +667,7 @@ public void testAlteringTTLFromTableToLevel2() throws Exception { globalConnection.createStatement().execute(dml); //Clearing cache as MetaDataCaching is not there for TTL usecase - globalConnection.unwrap(PhoenixConnection.class).getQueryServices().clearCache(); + globalConnection.unwrap(PhoenixMonitoredConnection.class).getQueryServices().clearCache(); assertTTLForGivenEntity(globalConnection, tableName, TTL_NOT_DEFINED); assertTTLForGivenEntity(globalConnection, globalViewName, TTL_NOT_DEFINED); @@ -682,7 +680,7 @@ public void testAlteringTTLFromTableToLevel2() throws Exception { tenantConnection.createStatement().execute(dml); //Clearing cache again - globalConnection.unwrap(PhoenixConnection.class).getQueryServices().clearCache(); + globalConnection.unwrap(PhoenixMonitoredConnection.class).getQueryServices().clearCache(); assertTTLForGivenEntity(globalConnection, tableName, TTL_NOT_DEFINED); assertTTLForGivenEntity(globalConnection, globalViewName, TTL_NOT_DEFINED); @@ -708,9 +706,9 @@ public void testAlteringTTLFromLevel1ToLevel2() throws Exception { String tenantViewName = schemaBuilder.getEntityTenantViewName(); String tenantViewIndexName = isMultiTenant ? schemaBuilder.getEntityTenantViewIndexName() : SKIP_ASSERT; - try (Connection globalConnection = DriverManager.getConnection(getUrl()); + try (Connection globalConnection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenantConnection = DriverManager.getConnection( - getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId())) { + getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { //All level entities should have TTL value equal to TTL defined at table level assertTTLForGivenPTable(globalConnection, table, TTL_NOT_DEFINED); assertTTLForGivenEntity(globalConnection, globalViewName, DEFAULT_TEST_TTL_VALUE_AT_GLOBAL); @@ -723,7 +721,7 @@ public void testAlteringTTLFromLevel1ToLevel2() throws Exception { globalConnection.createStatement().execute(dml); //Clearing cache as MetaDataCaching is not there for TTL usecase - globalConnection.unwrap(PhoenixConnection.class).getQueryServices().clearCache(); + globalConnection.unwrap(PhoenixMonitoredConnection.class).getQueryServices().clearCache(); assertTTLForGivenEntity(globalConnection, tableName, TTL_NOT_DEFINED); assertTTLForGivenEntity(globalConnection, globalViewName, TTL_NOT_DEFINED); @@ -736,7 +734,7 @@ public void testAlteringTTLFromLevel1ToLevel2() throws Exception { tenantConnection.createStatement().execute(dml); //Clearing cache again - globalConnection.unwrap(PhoenixConnection.class).getQueryServices().clearCache(); + globalConnection.unwrap(PhoenixMonitoredConnection.class).getQueryServices().clearCache(); assertTTLForGivenEntity(globalConnection, tableName, TTL_NOT_DEFINED); assertTTLForGivenEntity(globalConnection, globalViewName, TTL_NOT_DEFINED); @@ -762,9 +760,9 @@ public void testAlteringTTLFromLevel2ToTable() throws Exception { String tenantViewName = schemaBuilder.getEntityTenantViewName(); String tenantViewIndexName = isMultiTenant ? schemaBuilder.getEntityTenantViewIndexName() : SKIP_ASSERT; - try (Connection globalConnection = DriverManager.getConnection(getUrl()); + try (Connection globalConnection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenantConnection = DriverManager.getConnection( - getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId())) { + getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { //All level entities should have TTL value equal to TTL defined at table level assertTTLForGivenPTable(globalConnection, table, TTL_NOT_DEFINED); assertTTLForGivenEntity(globalConnection, globalViewName, TTL_NOT_DEFINED); @@ -777,7 +775,7 @@ public void testAlteringTTLFromLevel2ToTable() throws Exception { tenantConnection.createStatement().execute(dml); //Clearing cache as MetaDataCaching is not there for TTL usecase - globalConnection.unwrap(PhoenixConnection.class).getQueryServices().clearCache(); + globalConnection.unwrap(PhoenixMonitoredConnection.class).getQueryServices().clearCache(); assertTTLForGivenEntity(globalConnection, tableName, TTL_NOT_DEFINED); assertTTLForGivenEntity(globalConnection, globalViewName, TTL_NOT_DEFINED); @@ -790,7 +788,7 @@ public void testAlteringTTLFromLevel2ToTable() throws Exception { globalConnection.createStatement().execute(dml); //Clearing cache again - globalConnection.unwrap(PhoenixConnection.class).getQueryServices().clearCache(); + globalConnection.unwrap(PhoenixMonitoredConnection.class).getQueryServices().clearCache(); assertTTLForGivenEntity(globalConnection, tableName, ALTER_TEST_TTL_VALUE); assertTTLForGivenEntity(globalConnection, globalViewName, ALTER_TEST_TTL_VALUE); @@ -817,9 +815,9 @@ public void testAlteringTTLFromLevel2ToLevel1() throws Exception { String tenantViewName = schemaBuilder.getEntityTenantViewName(); String tenantViewIndexName = isMultiTenant ? schemaBuilder.getEntityTenantViewIndexName() : SKIP_ASSERT; - try (Connection globalConnection = DriverManager.getConnection(getUrl()); + try (Connection globalConnection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Connection tenantConnection = DriverManager.getConnection( - getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId())) { + getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { //All level entities should have TTL value equal to TTL defined at table level assertTTLForGivenPTable(globalConnection, table, TTL_NOT_DEFINED); assertTTLForGivenEntity(globalConnection, globalViewName, TTL_NOT_DEFINED); @@ -833,7 +831,7 @@ public void testAlteringTTLFromLevel2ToLevel1() throws Exception { //Clearing cache as MetaDataCaching is not there for TTL usecase //Clearing cache as MetaDataCaching is not there for TTL usecase - globalConnection.unwrap(PhoenixConnection.class).getQueryServices().clearCache(); + globalConnection.unwrap(PhoenixMonitoredConnection.class).getQueryServices().clearCache(); assertTTLForGivenEntity(globalConnection, tableName, TTL_NOT_DEFINED); assertTTLForGivenEntity(globalConnection, globalViewName, TTL_NOT_DEFINED); @@ -847,7 +845,7 @@ public void testAlteringTTLFromLevel2ToLevel1() throws Exception { //Clearing cache again //Clearing cache as MetaDataCaching is not there for TTL usecase - globalConnection.unwrap(PhoenixConnection.class).getQueryServices().clearCache(); + globalConnection.unwrap(PhoenixMonitoredConnection.class).getQueryServices().clearCache(); assertTTLForGivenEntity(globalConnection, tableName, TTL_NOT_DEFINED); assertTTLForGivenEntity(globalConnection, globalViewName, ALTER_TEST_TTL_VALUE); 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 4f0b50bb029..8c51fd43b7d 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,6 +18,8 @@ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +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.assertNotNull; @@ -60,6 +62,7 @@ import org.apache.hadoop.mapreduce.lib.output.NullOutputFormat; import org.apache.phoenix.iterate.TestingMapReduceParallelScanGrouper; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.mapreduce.PhoenixOutputFormat; import org.apache.phoenix.mapreduce.PhoenixTestingInputFormat; import org.apache.phoenix.mapreduce.index.PhoenixIndexDBWritable; @@ -69,6 +72,7 @@ import org.apache.phoenix.schema.types.PDouble; import org.apache.phoenix.schema.types.PhoenixArray; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.junit.Assert; import org.junit.Before; @@ -79,7 +83,6 @@ import org.junit.runners.Parameterized; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - @Category(NeedsOwnMiniClusterTest.class) @RunWith(Parameterized.class) public class TableSnapshotReadsMapReduceIT extends BaseTest { @@ -126,14 +129,18 @@ public static synchronized Collection snapshotRestoreDoneExternallyPara @BeforeClass public static synchronized void doSetup() throws Exception { Map props = Maps.newHashMapWithExpectedSize(1); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } getUtility().getAdmin().balancerSwitch(false, true); } @Before public void before() throws SQLException, IOException { // create table - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { tableName = generateUniqueName(); conn.createStatement().execute(String.format(CREATE_TABLE, tableName)); conn.commit(); @@ -189,7 +196,7 @@ public void testSnapshotMapReduceJobNotImpactingTableMapReduceJob() throws Excep TestingMapReduceParallelScanGrouper.clearNumCallsToGetRegionBoundaries(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { // create table tableName = generateUniqueName(); conn.createStatement().execute(String.format(CREATE_TABLE, tableName)); @@ -213,7 +220,7 @@ private Job createAndTestJob(Connection conn) conn.createStatement().execute(String.format(CREATE_STOCK_TABLE, stockTableName)); conn.createStatement().execute(String.format(CREATE_STOCK_STATS_TABLE, stockStatsTableName)); conn.commit(); - final Configuration conf = ((PhoenixConnection) conn).getQueryServices().getConfiguration(); + final Configuration conf = ((PhoenixMonitoredConnection) conn).getQueryServices().getConfiguration(); Job job = Job.getInstance(conf); PhoenixMapReduceUtil.setInput(job, MapReduceIT.StockWritable.class, PhoenixTestingInputFormat.class, stockTableName, null, STOCK_NAME, RECORDING_YEAR, "0." + RECORDINGS_QUARTER); @@ -271,7 +278,7 @@ private void configureJob(Job job, String tableName, String inputQuery, String c Assert.assertTrue(job.waitForCompletion(true)); // verify the result, should match the values at the corresponding timestamp - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty("CurrentSCN", Long.toString(timestamp)); StringBuilder selectQuery = new StringBuilder("SELECT * FROM " + tableName); @@ -330,7 +337,7 @@ private void upsertRecord(PreparedStatement stmt, String name, int year, Double[ } private void upsertData(String tableName) throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); PreparedStatement stmt = conn.prepareStatement(String.format(UPSERT, tableName)); upsertRecord(stmt, "AAAA", "JHHD", 37); upsertRecord(stmt, "BBBB", "JSHJ", 224); @@ -342,7 +349,7 @@ private void upsertData(String tableName) throws SQLException { } private void upsertDataBeforeSplit(String tableName) throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); PreparedStatement stmt = conn.prepareStatement(String.format(UPSERT, tableName)); upsertRecord(stmt, "CCCC", "SSDD", RANDOM.nextInt()); for (int i = 0; i < 100; i++) { @@ -378,8 +385,8 @@ private void upsertAndSnapshot(String tableName, boolean shouldSplit, Configurat } TableName hbaseTableName = TableName.valueOf(tableName); - try (Connection conn = DriverManager.getConnection(getUrl()); - Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { if (shouldSplit) { splitTableSync(admin, hbaseTableName, Bytes.toBytes("CCCC"), 2); @@ -449,8 +456,8 @@ private void snapshotCreateSync(TableName hbaseTableName, } private void deleteSnapshotIfExists(String snapshotName) throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); - Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin()) { List snapshotDescriptions = admin.listSnapshots(); boolean isSnapshotPresent = false; if (snapshotDescriptions != null && !snapshotDescriptions.isEmpty()) { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TableTTLIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TableTTLIT.java index 1d68ce776c7..8ed1074ca8d 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TableTTLIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TableTTLIT.java @@ -50,8 +50,9 @@ import java.util.Properties; import java.util.Random; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.*; - @Category(NeedsOwnMiniClusterTest.class) @RunWith(Parameterized.class) public class TableTTLIT extends BaseTest { @@ -87,7 +88,11 @@ public static synchronized void doSetup() throws Exception { props.put(BaseScannerRegionObserverConstants.PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY, Integer.toString(MAX_LOOKBACK_AGE)); props.put("hbase.procedure.remote.dispatcher.delay.msec", "0"); props.put(QueryServices.PHOENIX_VIEW_TTL_ENABLED, Boolean.toString(false)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @Before @@ -162,7 +167,7 @@ public void testMaskingAndMajorCompaction() throws Exception { final int maxMaskingCounter = 2 * ttl; final int maxVerificationCounter = 2 * ttl; final byte[] rowKey = Bytes.toBytes("a"); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tableName = generateUniqueName(); createTable(tableName); conn.createStatement().execute("Alter Table " + tableName @@ -234,7 +239,7 @@ public void testMaskingAndMajorCompaction() throws Exception { long scnStart = Math.max(scn, startTime); for (scn = scnEnd; scn >= scnStart; scn -= 1000) { // Compare all row versions using scn queries - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(scn)); try (Connection scnConn = DriverManager.getConnection(url, props)) { compareRow(scnConn, tableName, noCompactTableName, "a", @@ -251,7 +256,7 @@ public void testMinorCompactionShouldNotRetainCellsWhenMaxLookbackIsDisabled() if (tableLevelMaxLookback == null || tableLevelMaxLookback != 0) { return; } - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tableName = generateUniqueName(); createTable(tableName); conn.createStatement().execute("Alter Table " + tableName @@ -279,7 +284,7 @@ public void testMinorCompactionShouldNotRetainCellsWhenMaxLookbackIsDisabled() rowUpdateCounter * (MAX_COLUMN_INDEX + 1)); } // Run one minor compaction (in case no minor compaction has happened yet) - TestUtil.minorCompact(utility, TableName.valueOf(tableName)); + TestUtil.minorCompact(getUtility(), TableName.valueOf(tableName)); assertEquals(TestUtil.getRawCellCount(conn, TableName.valueOf(tableName), Bytes.toBytes("a")), (MAX_COLUMN_INDEX + 1) * versions); } catch (AssertionError e) { @@ -291,7 +296,7 @@ public void testMinorCompactionShouldNotRetainCellsWhenMaxLookbackIsDisabled() @Test public void testRowSpansMultipleTTLWindows() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tableName = generateUniqueName(); createTable(tableName); String noCompactTableName = generateUniqueName(); @@ -320,7 +325,7 @@ public void testMultipleRowsWithUpdatesMoreThanTTLApart() throws Exception { if (tableLevelMaxLookback == null || tableLevelMaxLookback != 0) { return; } - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tableName = generateUniqueName(); createTable(tableName); conn.createStatement().execute("Alter Table " + tableName @@ -376,7 +381,7 @@ public void testMaskingGapAnalysis() throws Exception { if (tableLevelMaxLookback == null || tableLevelMaxLookback != 0) { return; } - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tableName = generateUniqueName(); createTable(tableName); conn.createStatement().execute("Alter Table " + tableName @@ -435,7 +440,7 @@ public void testMultipleUpdatesToSingleColumn() throws Exception { if (tableLevelMaxLookback == null || tableLevelMaxLookback != 0) { return; } - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tableName = generateUniqueName(); createTable(tableName); conn.createStatement().execute("Alter Table " + tableName @@ -472,7 +477,7 @@ public void testDeleteFamilyVersion() throws Exception { if (multiCF == true) { return; } - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String tableName = "T_" + generateUniqueName(); createTable(tableName); conn.createStatement().execute("Alter Table " + tableName @@ -632,7 +637,7 @@ private void compareRow(Connection conn, String tableName1, String tableName2, S } private void createTable(String tableName) throws SQLException { - try(Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String createSql; if (multiCF) { createSql = "create table " + tableName + diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantIdTypeIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantIdTypeIT.java index 8fe3a105ff3..9e2698884fa 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantIdTypeIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantIdTypeIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +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; @@ -34,6 +35,7 @@ import org.apache.phoenix.schema.SequenceNotFoundException; import org.apache.phoenix.schema.TableAlreadyExistsException; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; @@ -41,24 +43,23 @@ import org.junit.runners.Parameterized.Parameters; import org.apache.phoenix.thirdparty.com.google.common.collect.Lists; - @Category(ParallelStatsDisabledTest.class) @RunWith(Parameterized.class) public class TenantIdTypeIT extends ParallelStatsDisabledIT { private Connection regularConnection(String url) throws SQLException { - return DriverManager.getConnection(url); + return DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES)); } private Connection tenantConnection(String url) throws SQLException { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); String tenantIdProperty = this.tenantId.replaceAll("\'", ""); props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantIdProperty); return DriverManager.getConnection(url, props); } private Connection inconvertibleConnection(String url) throws SQLException { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); String tenantIdProperty = "ABigOlString"; props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantIdProperty); return DriverManager.getConnection(url, props); 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 ab6e1831037..cff313cb0e2 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 @@ -20,6 +20,7 @@ import static org.apache.phoenix.exception.SQLExceptionCode.CANNOT_DROP_PK; import static org.apache.phoenix.exception.SQLExceptionCode.CANNOT_MUTATE_TABLE; import static org.apache.phoenix.exception.SQLExceptionCode.TABLE_UNDEFINED; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.KEY_SEQ; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.ORDINAL_POSITION; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CATALOG_SCHEMA; @@ -54,6 +55,7 @@ import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.QueryServicesOptions; import org.apache.phoenix.schema.ColumnAlreadyExistsException; import org.apache.phoenix.schema.ColumnNotFoundException; @@ -70,7 +72,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsEnabledTest.class) public class TenantSpecificTablesDDLIT extends BaseTenantSpecificTablesIT { @@ -78,7 +79,7 @@ public class TenantSpecificTablesDDLIT extends BaseTenantSpecificTablesIT { public void testCreateTenantSpecificTable() throws Exception { // ensure we didn't create a physical HBase table for the tenant-specific table Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); - Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin(); + Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin(); assertEquals(0, admin.listTableDescriptors(Pattern.compile(TENANT_TABLE_NAME)).size()); } @@ -209,7 +210,7 @@ public void testTenantSpecificTableCanDeclarePK() throws SQLException { @Test(expected=ColumnAlreadyExistsException.class) public void testTenantSpecificTableCannotOverrideParentCol() throws SQLException { - createTestTable(PHOENIX_JDBC_TENANT_SPECIFIC_URL, "CREATE VIEW " + generateUniqueName() + " ( \n" + + createTestTable(PHOENIX_JDBC_TENANT_SPECIFIC_URL, "CREATE VIEW " + generateUniqueName() + " ( \n" + " \"user\" INTEGER) AS SELECT *\n" + " FROM " + PARENT_TABLE_NAME); } @@ -326,7 +327,7 @@ public void testDisallowDropParentTableWithExistingTenantTable() throws Exceptio @Test public void testAllowDropParentTableWithCascadeAndSingleTenantTable() throws Exception { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - Connection conn = DriverManager.getConnection(getUrl(), props); + Connection conn = DriverManager.getConnection(getUrl(), props); Connection connTenant = null; try { @@ -424,11 +425,17 @@ public void testAllDropParentTableWithCascadeWithMultipleTenantTablesAndIndexes( private void validateTenantViewIsDropped(Connection connTenant) throws SQLException { try { - connTenant.unwrap(PhoenixConnection.class).getTableNoCache(TENANT_TABLE_NAME); + connTenant.unwrap(PhoenixMonitoredConnection.class).getTableNoCache(TENANT_TABLE_NAME); fail("Tenant specific view " + TENANT_TABLE_NAME + " should have been dropped when parent was dropped"); - } catch (TableNotFoundException e) { + } catch (Exception e) { //Expected + if (Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))) { + assertTrue(e.getCause() instanceof TableNotFoundException); + } else{ + assertTrue(e instanceof TableNotFoundException); + } +// } // Try and drop tenant view, should throw TableNotFoundException try { @@ -544,7 +551,7 @@ public void testTableMetadataScan() throws Exception { props.clear(); conn.close(); } - + props = PropertiesUtil.deepCopy(TEST_PROPERTIES); conn = DriverManager.getConnection(PHOENIX_JDBC_TENANT_SPECIFIC_URL, props); try { // make sure tenant-specific connections only see their own tables and the global tables @@ -634,7 +641,7 @@ public void testIndexHintWithTenantView() throws Exception { String viewName = generateUniqueName(); String fullViewName = SchemaUtil.getTableName(schemaName, viewName); String viewIndexName = generateUniqueName(); - try(Connection conn = DriverManager.getConnection(getUrl()); + try(Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { String createDataTable = "create table " + fullDataTableName + " (orgid varchar(10) not null, " + "id1 varchar(10) not null, id2 varchar(10) not null, id3 integer not null, " @@ -644,12 +651,12 @@ public void testIndexHintWithTenantView() throws Exception { stmt.execute("create view " + fullViewName + " as select * from " + fullDataTableName); stmt.execute("create index " + viewIndexName + " on " + fullViewName + "(id3, id2, id1) include (val1, val2)"); } - try(Connection conn = DriverManager.getConnection(PHOENIX_JDBC_TENANT_SPECIFIC_URL); + try(Connection conn = DriverManager.getConnection(PHOENIX_JDBC_TENANT_SPECIFIC_URL, PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { String grandChildViewName = generateUniqueName(); String fullGrandChildViewName = SchemaUtil.getTableName(schemaName, grandChildViewName); stmt.execute("create view " + fullGrandChildViewName + " as select * from " + fullViewName); - PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pconn = conn.unwrap(PhoenixMonitoredConnection.class); pconn.getTableNoCache(pconn.getTenantId(), fullGrandChildViewName); stmt.execute("upsert into " + fullGrandChildViewName + " values ('a1', 'a2', 3, 'a4', 'a5')"); conn.commit(); 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 3f406f72e33..4a7ce4e7e3b 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 @@ -41,7 +41,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsEnabledTest.class) public class TenantSpecificTablesDMLIT extends BaseTenantSpecificTablesIT { @@ -61,7 +60,7 @@ public void testPointLookupOnBaseTable() throws Exception { String ddl = String.format("CREATE TABLE %s (ORG_ID CHAR(15) NOT NULL, KP CHAR(3) NOT NULL, V1 INTEGER, V2 VARCHAR," + "CONSTRAINT PK PRIMARY KEY(ORG_ID, KP)) MULTI_TENANT=true", tableName); int nRows = 16; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute(ddl); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); @@ -265,7 +264,7 @@ public void testDeleteOnlyDeletesTenantData() throws Exception { conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, \"user\") values ('AC/DC', 'abc', 1, 'Bon Scott')"); conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, \"user\") values ('" + TENANT_ID + "', '" + TENANT_TYPE_ID + "', 1, 'Billy Gibbons')"); conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, \"user\") values ('" + TENANT_ID + "', 'def', 1, 'Billy Gibbons')"); - + conn = DriverManager.getConnection(PHOENIX_JDBC_TENANT_SPECIFIC_URL, props); conn.setAutoCommit(true); int count = conn.createStatement().executeUpdate("delete from " + TENANT_TABLE_NAME); @@ -294,7 +293,7 @@ public void testDeleteWhenImmutableIndex() throws Exception { conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, \"user\") values ('AC/DC', 'abc', 1, 'Bon Scott')"); conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, \"user\") values ('" + TENANT_ID + "', '" + TENANT_TYPE_ID + "', 1, 'Billy Gibbons')"); conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME + " (tenant_id, tenant_type_id, id, \"user\") values ('" + TENANT_ID + "', 'def', 1, 'Billy Gibbons')"); - + Connection tsConn = DriverManager.getConnection(PHOENIX_JDBC_TENANT_SPECIFIC_URL, props); tsConn.setAutoCommit(true); tsConn.createStatement().executeUpdate("create index idx1 on " + TENANT_TABLE_NAME + "(\"user\")"); @@ -324,7 +323,7 @@ public void testDeleteOnlyDeletesTenantDataWithNoTenantTypeId() throws Exception conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME_NO_TENANT_TYPE_ID + " (tenant_id, id, \"user\") values ('AC/DC', 1, 'Bon Scott')"); conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME_NO_TENANT_TYPE_ID + " (tenant_id, id, \"user\") values ('" + TENANT_ID + "', 1, 'Billy Gibbons')"); conn.createStatement().executeUpdate("upsert into " + PARENT_TABLE_NAME_NO_TENANT_TYPE_ID + " (tenant_id, id, \"user\") values ('" + TENANT_ID + "', 2, 'Billy Gibbons')"); - + Connection tsConn = DriverManager.getConnection(PHOENIX_JDBC_TENANT_SPECIFIC_URL, props); tsConn.setAutoCommit(true); int count = tsConn.createStatement().executeUpdate("delete from " + TENANT_TABLE_NAME_NO_TENANT_TYPE_ID); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificViewIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificViewIndexIT.java index 6d60fb42068..0fef2a54ae0 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificViewIndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificViewIndexIT.java @@ -20,6 +20,7 @@ import static org.apache.phoenix.util.MetaDataUtil.getViewIndexSequenceName; import static org.apache.phoenix.util.MetaDataUtil.getViewIndexSequenceSchemaName; import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB; +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.assertNull; @@ -41,12 +42,12 @@ import org.apache.phoenix.schema.ColumnNotFoundException; import org.apache.phoenix.schema.PNameFactory; import org.apache.phoenix.util.MetaDataUtil; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.PhoenixRuntime; import org.apache.phoenix.util.QueryUtil; import org.apache.phoenix.util.SchemaUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(NeedsOwnMiniClusterTest.class) public class TenantSpecificViewIndexIT extends BaseTenantSpecificViewIndexIT { @@ -94,7 +95,7 @@ public void testMultiCFViewLocalIndex() throws Exception { } private void createTableAndValidate(String tableName, boolean isNamespaceEnabled) throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); if (isNamespaceEnabled) { props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.toString(true)); } @@ -136,7 +137,7 @@ private void testMultiCFViewIndex(boolean localIndex, boolean isNamespaceEnabled String sequenceSchemaName = getViewIndexSequenceSchemaName(PNameFactory.newName(tableName), isNamespaceEnabled); verifySequenceValue(null, sequenceNameA, sequenceSchemaName, Short.MIN_VALUE + 2L); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId2); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { conn.createStatement().execute("DROP VIEW " + viewName2); @@ -145,14 +146,14 @@ private void testMultiCFViewIndex(boolean localIndex, boolean isNamespaceEnabled try (Connection conn = DriverManager.getConnection(getUrl(), props)) { conn.createStatement().execute("DROP VIEW " + viewName1); } - DriverManager.getConnection(getUrl()).createStatement().execute("DROP TABLE " + tableName + " CASCADE"); + DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).createStatement().execute("DROP TABLE " + tableName + " CASCADE"); verifySequenceNotExists(null, sequenceNameA, sequenceSchemaName); } private void createViewAndIndexesWithTenantId(String tableName, String viewName, boolean localIndex, String tenantId, boolean isNamespaceMapped, long indexIdOffset) throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); String indexName = "I_"+ generateUniqueName(); String schemaName = SchemaUtil.getSchemaNameFromFullName(viewName); String fullIndexName = SchemaUtil.getTableName(schemaName, indexName); @@ -286,7 +287,7 @@ public void testNonPaddedTenantId() throws Exception { String viewName = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); String ddl = "CREATE TABLE " + tableName + " (tenantId char(15) NOT NULL, pk1 varchar NOT NULL, pk2 INTEGER NOT NULL, val1 VARCHAR CONSTRAINT pk primary key (tenantId,pk1,pk2)) MULTI_TENANT = true"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute(ddl); String dml = "UPSERT INTO " + tableName + " (tenantId, pk1, pk2, val1) VALUES (?, ?, ?, ?)"; PreparedStatement stmt = conn.prepareStatement(dml); @@ -309,7 +310,7 @@ public void testNonPaddedTenantId() throws Exception { // get a tenant specific url. String tenantUrl = getUrl() + ';' + PhoenixRuntime.TENANT_ID_ATTRIB + '=' + tenantId1; - Connection tenantConn = DriverManager.getConnection(tenantUrl); + Connection tenantConn = DriverManager.getConnection(tenantUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES)); // create a tenant specific view. tenantConn.createStatement().execute("CREATE VIEW " + viewName + " AS select * from " + tableName); @@ -336,10 +337,9 @@ public void testOverlappingDatesFilter() throws Exception { + "PARENT_ID CHAR(15) NOT NULL," + "CREATED_DATE DATE NOT NULL " + "CONSTRAINT PK PRIMARY KEY (ORGANIZATION_ID, PARENT_TYPE, PARENT_ID, CREATED_DATE DESC)" - + ") VERSIONS=1,MULTI_TENANT=true,REPLICATION_SCOPE=1"; - - try (Connection conn = DriverManager.getConnection(getUrl()); - Connection viewConn = DriverManager.getConnection(tenantUrl) ) { + + ") VERSIONS=1,MULTI_TENANT=true,REPLICATION_SCOPE=1"; + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Connection viewConn = DriverManager.getConnection(tenantUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES)) ) { // create table conn.createStatement().execute(ddl); // create index @@ -397,9 +397,8 @@ public void testOverlappingDatesFilter() throws Exception { String TENANT_VIEW_TEMPLATE = "CREATE VIEW IF NOT EXISTS %s AS SELECT * FROM %s"; String INDEX_TEMPLATE = "CREATE INDEX IF NOT EXISTS %s ON %s(%s) INCLUDE (%s)"; - - try (Connection globalConn = DriverManager.getConnection(getUrl()); - Connection tenantConnection = DriverManager.getConnection(tenantConnectionUrl)) { + try (Connection globalConn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Connection tenantConnection = DriverManager.getConnection(tenantConnectionUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { globalConn.createStatement().execute(String.format(BASE_TABLE_TEMPLATE, baseTable)); globalConn.createStatement() @@ -416,7 +415,7 @@ public void testOverlappingDatesFilter() throws Exception { } } - try (Connection readConnection = DriverManager.getConnection(tenantConnectionUrl)) { + try (Connection readConnection = DriverManager.getConnection(tenantConnectionUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { // SQL where index is selected String planWithIndex = diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificViewIndexSaltedIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificViewIndexSaltedIT.java index f6a123b92e8..7f850223b80 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificViewIndexSaltedIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TenantSpecificViewIndexSaltedIT.java @@ -24,7 +24,6 @@ import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; - @Category(NeedsOwnMiniClusterTest.class) @RunWith(Parameterized.class) public class TenantSpecificViewIndexSaltedIT extends BaseTenantSpecificViewIndexIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertBindNullParamToCaseExprIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TestUpsertBindNullParamToCaseExprIT.java similarity index 96% rename from phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertBindNullParamToCaseExprIT.java rename to phoenix-core/src/it/java/org/apache/phoenix/end2end/TestUpsertBindNullParamToCaseExprIT.java index b56a235a5f7..d2d70572f59 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertBindNullParamToCaseExprIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TestUpsertBindNullParamToCaseExprIT.java @@ -35,17 +35,22 @@ import java.util.HashMap; import java.util.Properties; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @Category(ParallelStatsDisabledTest.class) -public class UpsertBindNullParamToCaseExprIT extends BaseTest { +public class TestUpsertBindNullParamToCaseExprIT extends BaseTest { @BeforeClass public static synchronized void doSetup() throws Exception { - setUpTestDriver(new ReadOnlyProps(new HashMap<>())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(new HashMap<>()), new ReadOnlyProps(new HashMap<>())); + } else { + setUpTestDriver(new ReadOnlyProps(new HashMap<>())); + } } @AfterClass diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TimeZoneDisplacementIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TimeZoneDisplacementIT.java index 5c6c99a90b6..e387dcbf9e4 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TimeZoneDisplacementIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TimeZoneDisplacementIT.java @@ -30,13 +30,13 @@ import java.util.TimeZone; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.util.DateUtil; import org.apache.phoenix.util.PropertiesUtil; import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsEnabledTest.class) public class TimeZoneDisplacementIT extends ParallelStatsEnabledIT { @@ -45,10 +45,10 @@ public void testCompliantCorrection() throws Exception { String tableName = generateUniqueName(); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.put(QueryServices.APPLY_TIME_ZONE_DISPLACMENT_ATTRIB, Boolean.TRUE.toString()); - try (PhoenixConnection conn = - (PhoenixConnection) DriverManager.getConnection(getUrl(), props); - Statement stmt = conn.createStatement(); - PreparedStatement insertPstmt = + try (PhoenixMonitoredConnection conn = + (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), props); + Statement stmt = conn.createStatement(); + PreparedStatement insertPstmt = conn.prepareStatement("upsert into " + tableName + " (ID, D1, D2, T1, T2, S1, S2, UD1, UD2, UT1, UT2, US1, US2) VALUES" + " (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ")) { @@ -120,8 +120,8 @@ public void testPhoenix5066() throws Exception { String tableName = generateUniqueName(); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.put(QueryServices.APPLY_TIME_ZONE_DISPLACMENT_ATTRIB, Boolean.TRUE.toString()); - try (PhoenixConnection conn = - (PhoenixConnection) DriverManager.getConnection(getUrl(), props); + try (PhoenixMonitoredConnection conn = + (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), props); Statement stmt = conn.createStatement(); PreparedStatement insertPstmt = conn.prepareStatement("upsert into " + tableName + " (ID, D, T, S) VALUES" @@ -173,8 +173,8 @@ public void testCurrent() throws Exception { // is different // We are testing that the displacement gets applied both ways props.put(QueryServices.APPLY_TIME_ZONE_DISPLACMENT_ATTRIB, Boolean.TRUE.toString()); - try (PhoenixConnection conn = - (PhoenixConnection) DriverManager.getConnection(getUrl(), props); + try (PhoenixMonitoredConnection conn = + (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), props); Statement stmt = conn.createStatement();) { conn.setAutoCommit(true); stmt.executeUpdate("create table " + tableName + " (ID integer primary key," @@ -220,8 +220,8 @@ public void testRowTimestamp() throws Exception { String tableName = generateUniqueName(); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.put(QueryServices.APPLY_TIME_ZONE_DISPLACMENT_ATTRIB, Boolean.TRUE.toString()); - try (PhoenixConnection conn = - (PhoenixConnection) DriverManager.getConnection(getUrl(), props); + try (PhoenixMonitoredConnection conn = + (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), props); Statement stmt = conn.createStatement(); PreparedStatement upsertStmt = conn.prepareStatement( @@ -303,8 +303,8 @@ public void testGetObjectWithNullValue() throws Exception { String tableName = generateUniqueName(); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.put(QueryServices.APPLY_TIME_ZONE_DISPLACMENT_ATTRIB, Boolean.TRUE.toString()); - try (PhoenixConnection conn = - (PhoenixConnection) DriverManager.getConnection(getUrl(), props)) { + try (PhoenixMonitoredConnection conn = + (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), props)) { conn.setAutoCommit(true); try (Statement stmt = conn.createStatement()) { stmt.execute("CREATE TABLE " + tableName + diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TimezoneOffsetFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TimezoneOffsetFunctionIT.java index 9ab72088ab6..362b3d99e03 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TimezoneOffsetFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TimezoneOffsetFunctionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -31,16 +32,16 @@ import java.util.TimeZone; import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class TimezoneOffsetFunctionIT extends ParallelStatsDisabledIT { @Test public void testTimezoneOffset() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String timezone_offset_test = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + timezone_offset_test + " (k1 INTEGER NOT NULL, dates DATE CONSTRAINT pk PRIMARY KEY (k1))"; @@ -65,7 +66,7 @@ public void testTimezoneOffset() throws Exception { @Test public void testUnknownTimezone() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String timezone_offset_test = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + timezone_offset_test + " (k1 INTEGER NOT NULL, dates DATE CONSTRAINT pk PRIMARY KEY (k1))"; @@ -90,7 +91,7 @@ public void testUnknownTimezone() throws Exception { @Test public void testInRowKeyDSTTimezoneDesc() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String timezone_offset_test = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + timezone_offset_test + " " + "(k1 INTEGER NOT NULL, dates DATE NOT NULL CONSTRAINT pk PRIMARY KEY (k1, dates DESC))"; @@ -115,7 +116,7 @@ public void testInRowKeyDSTTimezoneDesc() throws Exception { @Test public void testBothParametersNull() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String timezone_offset_test = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + timezone_offset_test + " " + "(k1 INTEGER NOT NULL, dates DATE, v1 VARCHAR CONSTRAINT pk PRIMARY KEY (k1))"; @@ -135,7 +136,7 @@ public void testBothParametersNull() throws Exception { @Test public void timezoneParameterNull() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String timezone_offset_test = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + timezone_offset_test + " " + "(k1 INTEGER NOT NULL, dates DATE, v1 VARCHAR CONSTRAINT pk PRIMARY KEY (k1))"; @@ -156,7 +157,7 @@ public void timezoneParameterNull() throws Exception { @Test public void dateParameterNull() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String timezone_offset_test = generateUniqueName(); String ddl = "CREATE TABLE IF NOT EXISTS " + timezone_offset_test + " " + "(k1 INTEGER NOT NULL, dates DATE, v1 VARCHAR CONSTRAINT pk PRIMARY KEY (k1))"; @@ -177,7 +178,7 @@ public void dateParameterNull() throws Exception { @Test public void testInsertingRetrivingTimestamp() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String t = generateUniqueName(); String ddl = "CREATE TABLE " + t + " (K INTEGER NOT NULL PRIMARY KEY, V TIMESTAMP)"; conn.createStatement().execute(ddl); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToCharFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToCharFunctionIT.java index ba26fd1806d..ec17f64a337 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToCharFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToCharFunctionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +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; @@ -37,6 +38,7 @@ import java.util.TimeZone; import org.apache.phoenix.expression.function.ToCharFunction; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -48,7 +50,6 @@ * * @since 0.1 */ - @Category(ParallelStatsDisabledTest.class) public class ToCharFunctionIT extends ParallelStatsDisabledIT { @@ -80,7 +81,7 @@ public void initTable() throws Exception { "col_decimal decimal\n" + "CONSTRAINT my_pk PRIMARY KEY (pk))"; createTestTable(getUrl(), ddl); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.setAutoCommit(false); PreparedStatement stmt = conn.prepareStatement( @@ -214,7 +215,7 @@ private void runOneRowFilterQuery(String oneRowQuery, int pkValue) throws Except } private void runOneRowQueryTest(String oneRowQuery, Integer pkValue, String projectedValue) throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { PreparedStatement statement = conn.prepareStatement(oneRowQuery); ResultSet rs = statement.executeQuery(); @@ -238,7 +239,7 @@ private DateFormat getGMTDateFormat(String pattern) { @Test public void testToCharWithCloneMethod() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "create table " + tableName + " (k varchar primary key, v integer[])"; conn.createStatement().execute(ddl); @@ -254,7 +255,7 @@ public void testToCharWithCloneMethod() throws SQLException { @Test public void testIndexedNull() throws SQLException { final String tableName = generateUniqueName(); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute("create table " + tableName + " (id integer primary key, ts1 timestamp, ts2 timestamp)"); conn.createStatement().execute("create index t_ts2_idx on " + tableName + " (ts2)"); @@ -273,7 +274,7 @@ public void testIndexedNull() throws SQLException { @Test public void testToChar100Times() throws Exception { String tableName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement statement = conn.createStatement()) { conn.setAutoCommit(true); statement.execute("create table " + tableName + diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToDateFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToDateFunctionIT.java index 48f7f1b77d7..48e8ed11e8e 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToDateFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToDateFunctionIT.java @@ -20,6 +20,7 @@ import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.TypeMismatchException; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -28,9 +29,9 @@ import java.sql.*; import java.util.Properties; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.*; - @Category(ParallelStatsDisabledTest.class) public class ToDateFunctionIT extends ParallelStatsDisabledIT { @@ -40,7 +41,7 @@ public class ToDateFunctionIT extends ParallelStatsDisabledIT { @Before public void setUp() throws SQLException { - conn = DriverManager.getConnection(getUrl()); + conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); } @After @@ -150,7 +151,7 @@ public void testToDate_LocalTimeZone() throws SQLException { @Test public void testToDate_CustomTimeZoneViaQueryServices() throws SQLException { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.DATE_FORMAT_TIMEZONE_ATTRIB, "GMT+1"); Connection customTimeZoneConn = DriverManager.getConnection(getUrl(), props); @@ -161,7 +162,7 @@ public void testToDate_CustomTimeZoneViaQueryServices() throws SQLException { @Test public void testToDate_CustomTimeZoneViaQueryServicesAndCustomFormat() throws SQLException { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.DATE_FORMAT_TIMEZONE_ATTRIB, "GMT+1"); Connection customTimeZoneConn = DriverManager.getConnection(getUrl(), props); @@ -173,7 +174,7 @@ public void testToDate_CustomTimeZoneViaQueryServicesAndCustomFormat() throws SQ @Test public void testTimestampCast() throws SQLException { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.DATE_FORMAT_TIMEZONE_ATTRIB, "GMT+1"); Connection customTimeZoneConn = DriverManager.getConnection(getUrl(), props); @@ -194,7 +195,7 @@ public void testTimestampCast() throws SQLException { @Test public void testUnsignedLongToTimestampCast() throws SQLException { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.DATE_FORMAT_TIMEZONE_ATTRIB, "GMT+1"); Connection conn = DriverManager.getConnection(getUrl(), props); conn.setAutoCommit(false); @@ -256,7 +257,7 @@ public void testVarcharToDateComparision() throws SQLException { @Test public void testToDateWithCloneMethod() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String tableName = generateUniqueName(); String ddl = "create table " + tableName + " (k varchar primary key, v varchar[])"; conn.createStatement().execute(ddl); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToNumberFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToNumberFunctionIT.java index 477f69f7d31..e6d229a364f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToNumberFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToNumberFunctionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +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; @@ -33,6 +34,7 @@ import org.apache.phoenix.expression.function.ToNumberFunction; import org.apache.phoenix.schema.types.PDecimal; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -45,7 +47,6 @@ * * @since 0.1 */ - @Category(ParallelStatsDisabledTest.class) public class ToNumberFunctionIT extends ParallelStatsDisabledIT { @@ -84,7 +85,7 @@ public static synchronized void tearDownAfterClass() { public static void initTable() throws Exception { createTestTable(getUrl(), TO_NUMBER_TABLE_DDL, null, null); - try (Connection conn = DriverManager.getConnection(url)) { + try (Connection conn = DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.setAutoCommit(false); PreparedStatement stmt = @@ -291,7 +292,7 @@ private void runOneRowQueryTest(String oneRowQuery, int expectedIntValue) throws private void runOneRowQueryTest(String oneRowQuery, boolean isIntegerColumn, Integer expectedIntValue, BigDecimal expectedDecimalValue) throws Exception { - try (Connection conn = DriverManager.getConnection(url)) { + try (Connection conn = DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { PreparedStatement statement = conn.prepareStatement(oneRowQuery); ResultSet rs = statement.executeQuery(); assertTrue(rs.next()); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TopNIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TopNIT.java index 429713dfb24..a10f33bf4c6 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TopNIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TopNIT.java @@ -26,6 +26,7 @@ import static org.apache.phoenix.util.TestUtil.ROW7; import static org.apache.phoenix.util.TestUtil.ROW8; import static org.apache.phoenix.util.TestUtil.ROW9; +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; @@ -35,10 +36,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class TopNIT extends ParallelStatsDisabledIT { @@ -47,7 +48,7 @@ public void testMultiOrderByExpr() throws Exception { String tenantId = getOrganizationId(); String tableName = initATableValues(null, tenantId, getDefaultSplits(tenantId), null, null, getUrl(), null); String query = "SELECT entity_id FROM " + tableName + " ORDER BY b_string, entity_id LIMIT 5"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { PreparedStatement statement = conn.prepareStatement(query); ResultSet rs = statement.executeQuery(); @@ -74,7 +75,7 @@ public void testDescMultiOrderByExpr() throws Exception { String tenantId = getOrganizationId(); String tableName = initATableValues(null, tenantId, getDefaultSplits(tenantId), null, null, getUrl(), null); String query = "SELECT entity_id FROM " + tableName + " ORDER BY b_string || entity_id desc LIMIT 5"; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { PreparedStatement statement = conn.prepareStatement(query); ResultSet rs = statement.executeQuery(); @@ -112,7 +113,7 @@ private void testTopNDelete(boolean autoCommit) throws Exception { initATableValues(null, tenantId, getDefaultSplits(tenantId), null, null, getUrl(), null); String query = "DELETE FROM " + tableName + " ORDER BY b_string, entity_id LIMIT 5"; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.setAutoCommit(autoCommit); PreparedStatement statement = conn.prepareStatement(query); statement.execute(); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TransactionalViewIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TransactionalViewIT.java index 8e727c324c4..730f853e4dd 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TransactionalViewIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TransactionalViewIT.java @@ -19,6 +19,7 @@ import static org.apache.phoenix.util.TestUtil.analyzeTable; import static org.apache.phoenix.util.TestUtil.getAllSplits; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import java.sql.Connection; @@ -29,6 +30,7 @@ import java.util.List; import org.apache.phoenix.query.KeyRange; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.util.TestUtil; import org.junit.Before; @@ -37,7 +39,6 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; - @Category(ParallelStatsEnabledTest.class) @RunWith(Parameterized.class) public class TransactionalViewIT extends ParallelStatsEnabledIT { @@ -66,8 +67,8 @@ public void generateTableNames() { @Test public void testReadOwnWritesWithStats() throws Exception { - try (Connection conn1 = DriverManager.getConnection(getUrl()); - Connection conn2 = DriverManager.getConnection(getUrl())) { + try (Connection conn1 = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Connection conn2 = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String ddl = "CREATE TABLE " + fullTableName + " (k INTEGER NOT NULL PRIMARY KEY, v1 DATE) TRANSACTIONAL=true,TRANSACTION_PROVIDER='" + transactionProvider + "'"; conn1.createStatement().execute(ddl); @@ -101,8 +102,8 @@ public void testReadOwnWritesWithStats() throws Exception { @Test public void testInvalidRowsWithStats() throws Exception { - try (Connection conn1 = DriverManager.getConnection(getUrl()); - Connection conn2 = DriverManager.getConnection(getUrl())) { + try (Connection conn1 = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Connection conn2 = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String ddl = "CREATE TABLE " + fullTableName + " (k INTEGER NOT NULL PRIMARY KEY, v1 DATE) TRANSACTIONAL=true,TRANSACTION_PROVIDER='" + transactionProvider + "'"; conn1.createStatement().execute(ddl); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TruncateFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TruncateFunctionIT.java index 55636d8afe6..cd24b2a2c6c 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/TruncateFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/TruncateFunctionIT.java @@ -17,9 +17,7 @@ */ package org.apache.phoenix.end2end; -import static org.apache.phoenix.util.TestUtil.ROW1; -import static org.apache.phoenix.util.TestUtil.ROW2; -import static org.apache.phoenix.util.TestUtil.ROW3; +import static org.apache.phoenix.util.TestUtil.*; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -34,11 +32,11 @@ import org.apache.phoenix.query.QueryConstants; import org.apache.phoenix.util.DateUtil; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.TestUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class TruncateFunctionIT extends ParallelStatsDisabledIT { private static final String DS1 = "1970-01-10 00:58:01.587"; @@ -58,7 +56,7 @@ public void testTruncate() throws Exception { String tenantId = getOrganizationId(); String tableName = generateUniqueName(); ensureTableCreated(url, tableName, TestUtil.ATABLE_NAME, null, null, null); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { PreparedStatement stmt = conn.prepareStatement( "upsert into " + tableName + "(" + diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UCFWithDisabledIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UCFWithDisabledIndexIT.java index e58f5a7859e..a663ada38d6 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UCFWithDisabledIndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UCFWithDisabledIndexIT.java @@ -29,6 +29,7 @@ import org.apache.phoenix.exception.PhoenixIOException; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixPreparedStatement; import org.apache.phoenix.protobuf.ProtobufUtil; import org.apache.phoenix.query.BaseTest; @@ -37,6 +38,7 @@ import org.apache.phoenix.schema.PTable; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; import org.apache.phoenix.util.ClientUtil; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.util.TestUtil; @@ -55,7 +57,9 @@ import java.util.Map; import java.util.Properties; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.query.QueryServices.DISABLE_VIEW_SUBTREE_VALIDATION; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; /** * Tests that use UPDATE_CACHE_FREQUENCY with some of the disabled index states that require @@ -76,7 +80,11 @@ private static void initCluster() throws Exception { props.put(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); props.put(DISABLE_VIEW_SUBTREE_VALIDATION, "true"); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()), new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @BeforeClass @@ -113,7 +121,7 @@ public void testUcfWithNoGetTableCalls() throws Throwable { final String index_view03 = "idx_v03_" + tableName; final String index_view04 = "idx_v04_" + tableName; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + tableName @@ -198,7 +206,7 @@ public void testUcfWithDisabledIndex1() throws Throwable { final String tableName = generateUniqueName(); final String indexName = "IDX_" + tableName; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { final Statement stmt = createIndexAndUpdateCoproc(conn, tableName, indexName, true); @@ -207,10 +215,18 @@ public void testUcfWithDisabledIndex1() throws Throwable { + "'c012', 'c013', 'c014')"); conn.commit(); throw new RuntimeException("Should not reach here"); - } catch (PhoenixIOException e) { - LOGGER.error("Error thrown. ", e); - Assert.assertTrue(e.getCause() instanceof DoNotRetryIOException); - Assert.assertTrue(e.getCause().getMessage().contains("Not allowed")); + } catch (Exception e) { + if(e instanceof SQLException) { + if(e.getCause() instanceof PhoenixIOException){ + LOGGER.error("Error thrown. ", e); + Assert.assertTrue(e.getCause().getCause() instanceof DoNotRetryIOException); + Assert.assertTrue(e.getCause().getCause().getMessage().contains("Not allowed")); + } + } else if(e instanceof PhoenixIOException) { + LOGGER.error("Error thrown. ", e); + Assert.assertTrue(e.getCause() instanceof DoNotRetryIOException); + Assert.assertTrue(e.getCause().getMessage().contains("Not allowed")); + } } finally { updateIndexToRebuild(conn, tableName, indexName); TestUtil.removeCoprocessor(conn, "SYSTEM.CATALOG", TestMetaDataEndpointImpl.class); @@ -291,7 +307,7 @@ private static void updateIndexToRebuild(Connection conn, String tableName, Stri stmt.execute("ALTER INDEX " + indexName + " ON " + tableName + " REBUILD"); - PTable indexTable = conn.unwrap(PhoenixConnection.class).getTableNoCache(indexName); + PTable indexTable = conn.unwrap(PhoenixMonitoredConnection.class).getTableNoCache(indexName); Assert.assertEquals(PIndexState.ACTIVE, indexTable.getIndexState()); // attach coproc that does not allow getTable RPC call @@ -348,7 +364,7 @@ private static Statement createIndexAndUpdateCoproc(Connection conn, // expected to call getTable conn.commit(); - PTable indexTable = conn.unwrap(PhoenixConnection.class).getTableNoCache(indexName); + PTable indexTable = conn.unwrap(PhoenixMonitoredConnection.class).getTableNoCache(indexName); if (alterIndexState) { Assert.assertEquals(PIndexState.DISABLE, indexTable.getIndexState()); } else { @@ -366,16 +382,24 @@ public void testUcfWithDisabledIndex2() throws Throwable { final String tableName = generateUniqueName(); final String indexName = "IDX_" + tableName; - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { final Statement stmt = createIndexAndUpdateCoproc(conn, tableName, indexName, true); stmt.execute("SELECT * FROM " + indexName); throw new RuntimeException("Should not reach here"); - } catch (PhoenixIOException e) { - LOGGER.error("Error thrown. ", e); - Assert.assertTrue(e.getCause() instanceof DoNotRetryIOException); - Assert.assertTrue(e.getCause().getMessage().contains("Not allowed")); + } catch (Exception e) { + if(e instanceof SQLException) { + if(e.getCause() instanceof PhoenixIOException){ + LOGGER.error("Error thrown. ", e); + Assert.assertTrue(e.getCause().getCause() instanceof DoNotRetryIOException); + Assert.assertTrue(e.getCause().getCause().getMessage().contains("Not allowed")); + } + } else if(e instanceof PhoenixIOException) { + LOGGER.error("Error thrown. ", e); + Assert.assertTrue(e.getCause() instanceof DoNotRetryIOException); + Assert.assertTrue(e.getCause().getMessage().contains("Not allowed")); + } } finally { updateIndexToRebuild(conn, tableName, indexName); TestUtil.removeCoprocessor(conn, "SYSTEM.CATALOG", TestMetaDataEndpointImpl.class); @@ -390,7 +414,7 @@ public void testUcfWithDisabledIndex3() throws Throwable { final String tableName = generateUniqueName(); final String indexName = "IDX_" + tableName; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.INDEX_CREATE_DEFAULT_STATE, PIndexState.CREATE_DISABLE.toString()); Connection conn = DriverManager.getConnection(getUrl(), props); @@ -403,10 +427,18 @@ public void testUcfWithDisabledIndex3() throws Throwable { + "'c012', 'c013', 'c014')"); conn.commit(); throw new RuntimeException("Should not reach here"); - } catch (PhoenixIOException e) { - LOGGER.error("Error thrown. ", e); - Assert.assertTrue(e.getCause() instanceof DoNotRetryIOException); - Assert.assertTrue(e.getCause().getMessage().contains("Not allowed")); + } catch (Exception e) { + if(e instanceof SQLException) { + if(e.getCause() instanceof PhoenixIOException){ + LOGGER.error("Error thrown. ", e); + Assert.assertTrue(e.getCause().getCause() instanceof DoNotRetryIOException); + Assert.assertTrue(e.getCause().getCause().getMessage().contains("Not allowed")); + } + } else if(e instanceof PhoenixIOException) { + LOGGER.error("Error thrown. ", e); + Assert.assertTrue(e.getCause() instanceof DoNotRetryIOException); + Assert.assertTrue(e.getCause().getMessage().contains("Not allowed")); + } } finally { updateIndexToRebuild(conn, tableName, indexName); TestUtil.removeCoprocessor(conn, "SYSTEM.CATALOG", TestMetaDataEndpointImpl.class); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UCFWithDisabledIndexWithDDLValidationIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UCFWithDisabledIndexWithDDLValidationIT.java index 74235aaa577..4a3dc0446ca 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UCFWithDisabledIndexWithDDLValidationIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UCFWithDisabledIndexWithDDLValidationIT.java @@ -27,6 +27,8 @@ import java.util.Map; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; + /** * Tests that use UPDATE_CACHE_FREQUENCY with some of the disabled index states that require * clients to override UPDATE_CACHE_FREQUENCY and perform metadata calls to retrieve PTable. @@ -45,7 +47,11 @@ private static void initCluster() throws Exception { props.put(QueryServices.PHOENIX_METADATA_INVALIDATE_CACHE_ENABLED, Boolean.toString(true)); props.put(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()), new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @BeforeClass diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UncoveredIndexWithRegionMovesIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UncoveredIndexWithRegionMovesIT.java index 91d793e966b..2b1b1281cc5 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UncoveredIndexWithRegionMovesIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UncoveredIndexWithRegionMovesIT.java @@ -30,6 +30,7 @@ import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.TestUtil; import org.junit.After; @@ -54,7 +55,9 @@ import static org.apache.phoenix.end2end.index.GlobalIndexCheckerIT.assertExplainPlan; import static org.apache.phoenix.end2end.index.GlobalIndexCheckerIT.assertExplainPlanWithLimit; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_PAGED_ROWS_COUNTER; +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.assertNotNull; @@ -103,7 +106,11 @@ public static synchronized void doSetup() throws Exception { props.put(HConstants.HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY, String.valueOf(1)); props.put(QueryServices.PHOENIX_POST_DUMMY_PROCESS, TestScanningResultPostDummyResultCaller.class.getName()); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @After @@ -207,7 +214,7 @@ public void testUncoveredQueryWithGroupBy() throws Exception { String dataTableName = generateUniqueName(); populateTable( dataTableName); // with two rows ('a', 'ab', 'abc', 'abcd') and ('b', 'bc', 'bcd', 'bcde') - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String indexTableName = generateUniqueName(); conn.createStatement().execute("CREATE UNCOVERED INDEX " + indexTableName + " on " + dataTableName + " (val1) "); @@ -295,7 +302,7 @@ private void testUncoveredUtil(boolean limit) throws Exception { hasTestStarted = true; String dataTableName = generateUniqueName(); populateTable(dataTableName); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String indexTableName = generateUniqueName(); conn.createStatement().execute("CREATE UNCOVERED INDEX " + indexTableName + " on " + dataTableName + " (val1) "); @@ -376,7 +383,7 @@ private void testUncoveredUtil(boolean limit) throws Exception { } private void populateTable(String tableName) throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute("create table " + tableName + " (id varchar(10) not null primary key, val1 varchar(10), val2 varchar(10)," + " val3 varchar(10))"); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UngroupedIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UngroupedIT.java index 411b2f2b83c..641ac76d198 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UngroupedIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UngroupedIT.java @@ -46,7 +46,6 @@ import org.junit.runners.MethodSorters; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; - @Category(ParallelStatsDisabledTest.class) @RunWith(Parameterized.class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UnionAllIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UnionAllIT.java index 728edc15e69..6d570174500 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UnionAllIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UnionAllIT.java @@ -43,7 +43,6 @@ import org.apache.phoenix.util.TestUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class UnionAllIT extends ParallelStatsDisabledIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpdatableViewRestrictionsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpdatableViewRestrictionsIT.java index b90ccb2d387..389677032f9 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpdatableViewRestrictionsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpdatableViewRestrictionsIT.java @@ -22,6 +22,7 @@ import org.apache.phoenix.schema.TableProperty; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; import org.junit.BeforeClass; @@ -41,6 +42,8 @@ import java.util.Properties; import static org.apache.phoenix.coprocessor.PhoenixMetaDataCoprocessorHost.PHOENIX_META_DATA_COPROCESSOR_CONF_KEY; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +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; @@ -63,8 +66,13 @@ public static synchronized void doSetup() throws Exception { ViewConcurrencyAndFailureIT.TestMetaDataRegionObserver.class .getName()); serverProps.put("hbase.coprocessor.abortonerror", "false"); - setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), - ReadOnlyProps.EMPTY_PROPS); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(serverProps.entrySet().iterator()), + ReadOnlyProps.EMPTY_PROPS); + } else { + setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), + ReadOnlyProps.EMPTY_PROPS); + } // Split SYSTEM.CATALOG once after the mini-cluster is started if (splitSystemCatalog) { // splitSystemCatalog is incompatible with the balancer chore @@ -108,7 +116,7 @@ private void createTable(Connection conn, String tableName) throws Exception { } private Connection getTenantConnection(final String tenantId) throws Exception { - Properties tenantProps = new Properties(); + Properties tenantProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); tenantProps.setProperty(QueryServices.PHOENIX_UPDATABLE_VIEW_RESTRICTION_ENABLED, "true"); return DriverManager.getConnection(getUrl(), tenantProps); @@ -135,7 +143,7 @@ public void testReadOnlyViewWithNonPkInWhere() throws Exception { String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String fullViewName = SchemaUtil.getTableName(SCHEMA3, generateUniqueName()); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.PHOENIX_UPDATABLE_VIEW_RESTRICTION_ENABLED, "true"); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { conn.setAutoCommit(true); @@ -162,7 +170,7 @@ public void testReadOnlyViewWithPkNotInOrderInWhere1() throws Exception { String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String fullViewName = SchemaUtil.getTableName(SCHEMA3, generateUniqueName()); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.PHOENIX_UPDATABLE_VIEW_RESTRICTION_ENABLED, "true"); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { conn.setAutoCommit(true); @@ -189,7 +197,7 @@ public void testReadOnlyViewWithPkNotInOrderInWhere2() throws Exception { String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String fullViewName = SchemaUtil.getTableName(SCHEMA3, generateUniqueName()); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.PHOENIX_UPDATABLE_VIEW_RESTRICTION_ENABLED, "true"); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { conn.setAutoCommit(true); @@ -220,7 +228,7 @@ public void testReadOnlyViewWithPkNotSameInWhere1() throws Exception { String fullViewName = SchemaUtil.getTableName(SCHEMA3, generateUniqueName()); String fullSiblingViewName = SchemaUtil.getTableName(SCHEMA3, generateUniqueName()); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.PHOENIX_UPDATABLE_VIEW_RESTRICTION_ENABLED, "true"); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { conn.setAutoCommit(true); @@ -258,7 +266,7 @@ public void testReadOnlyViewWithPkNotSameInWhere2() throws Exception { String fullViewName = SchemaUtil.getTableName(SCHEMA3, generateUniqueName()); String fullSiblingViewName = SchemaUtil.getTableName(SCHEMA3, generateUniqueName()); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.PHOENIX_UPDATABLE_VIEW_RESTRICTION_ENABLED, "true"); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { conn.setAutoCommit(true); @@ -296,7 +304,7 @@ public void testReadOnlyViewWithPkNotSameInWhere2() throws Exception { */ private void testUpdatableViewStartFromFirstPK(boolean multitenant, Integer nSaltBuckets) throws Exception { String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.PHOENIX_UPDATABLE_VIEW_RESTRICTION_ENABLED, "true"); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { conn.setAutoCommit(true); @@ -327,7 +335,7 @@ private void testReadOnlyViewNotStartFromFirstPK(boolean multitenant, Integer nS String fullViewName = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); String tenantId = TENANT1; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.PHOENIX_UPDATABLE_VIEW_RESTRICTION_ENABLED, "true"); try (Connection globalConn = DriverManager.getConnection(getUrl(), props); Connection tenantConn = getTenantConnection(tenantId)) { @@ -460,7 +468,7 @@ public void testReadOnlyViewOnUpdatableView1() throws Exception { String fullViewName = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); String fullChildViewName = SchemaUtil.getTableName(SCHEMA3, generateUniqueName()); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.PHOENIX_UPDATABLE_VIEW_RESTRICTION_ENABLED, "true"); Connection conn = DriverManager.getConnection(getUrl(), props); conn.setAutoCommit(true); @@ -493,7 +501,7 @@ public void testReadOnlyViewOnUpdatableView2() throws Exception { String fullViewName = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); String fullChildViewName = SchemaUtil.getTableName(SCHEMA3, generateUniqueName()); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.PHOENIX_UPDATABLE_VIEW_RESTRICTION_ENABLED, "true"); Connection conn = DriverManager.getConnection(getUrl(), props); conn.setAutoCommit(true); @@ -522,7 +530,7 @@ public void testUpdatableViewOnUpdatableView() throws Exception { String fullViewName = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); String fullChildViewName = SchemaUtil.getTableName(SCHEMA3, generateUniqueName()); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.PHOENIX_UPDATABLE_VIEW_RESTRICTION_ENABLED, "true"); Connection conn = DriverManager.getConnection(getUrl(), props); conn.setAutoCommit(true); @@ -557,7 +565,7 @@ public void testSiblingsUpdatableOnUpdatableView() throws Exception { String fullLeafViewName1 = SchemaUtil.getTableName(SCHEMA4, generateUniqueName()); String fullLeafViewName2 = SchemaUtil.getTableName(SCHEMA4, generateUniqueName()); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.PHOENIX_UPDATABLE_VIEW_RESTRICTION_ENABLED, "true"); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { createTable(conn, fullTableName); @@ -629,7 +637,7 @@ public void testUpdatableViewWithMultiTenantTable() throws Exception { final String view02 = SchemaUtil.getTableName(SCHEMA3, "v02_" + tableName); final String view03 = SchemaUtil.getTableName(SCHEMA4, "v03_" + tableName); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.PHOENIX_UPDATABLE_VIEW_RESTRICTION_ENABLED, "true"); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { final Statement stmt = conn.createStatement(); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpdateCacheAcrossDifferentClientsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpdateCacheAcrossDifferentClientsIT.java index a9d0f69cdaf..25ba4b33dbb 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpdateCacheAcrossDifferentClientsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpdateCacheAcrossDifferentClientsIT.java @@ -10,17 +10,18 @@ */ package org.apache.phoenix.end2end; +import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; import org.apache.hadoop.hbase.HConstants; +import org.apache.phoenix.jdbc.PhoenixDriver; +import org.apache.phoenix.jdbc.ZKConnectionInfo; +import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.thirdparty.com.google.common.base.Throwables; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.client.Table; import org.apache.phoenix.exception.PhoenixIOException; -import org.apache.phoenix.jdbc.PhoenixConnection; -import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; -import org.apache.phoenix.jdbc.PhoenixDriver; -import org.apache.phoenix.jdbc.ZKConnectionInfo; import org.apache.phoenix.query.BaseTest; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.query.QueryServicesOptions; @@ -31,6 +32,8 @@ import org.apache.phoenix.schema.TableNotFoundException; import org.apache.phoenix.util.IndexUtil; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; +import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; import org.junit.BeforeClass; import org.junit.Test; @@ -41,35 +44,47 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.Map; import java.util.Properties; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +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; - @Category(NeedsOwnMiniClusterTest.class) public class UpdateCacheAcrossDifferentClientsIT extends BaseTest { @BeforeClass public static synchronized void doSetup() throws Exception { - Configuration conf = HBaseConfiguration.create(); - HBaseTestingUtility hbaseTestUtil = new HBaseTestingUtility(conf); - setUpConfigForMiniCluster(conf); - conf.set(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS); - conf.set(QueryServices.DROP_METADATA_ATTRIB, Boolean.TRUE.toString()); - conf.set(QueryServices.MUTATE_BATCH_SIZE_ATTRIB, Integer.toString(3000)); - hbaseTestUtil.startMiniCluster(); - // establish url and quorum. Need to use PhoenixDriver and not PhoenixTestDriver - String zkQuorum = "localhost:" + hbaseTestUtil.getZkCluster().getClientPort(); - url = PhoenixRuntime.JDBC_PROTOCOL + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum; - DriverManager.registerDriver(PhoenixDriver.INSTANCE); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + Map props = Maps.newHashMapWithExpectedSize(1); + props.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS); + props.put(QueryServices.DROP_METADATA_ATTRIB, Boolean.TRUE.toString()); + props.put(QueryServices.MUTATE_BATCH_SIZE_ATTRIB, Integer.toString(3000)); + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()), new ReadOnlyProps(props.entrySet().iterator())); + url = CLUSTERS.getJdbcHAUrlWithoutPrincipal(); + + } else { + Configuration conf = HBaseConfiguration.create(); + HBaseTestingUtility hbaseTestUtil = new HBaseTestingUtility(conf); + setUpConfigForMiniCluster(conf); + conf.set(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS); + conf.set(QueryServices.DROP_METADATA_ATTRIB, Boolean.TRUE.toString()); + conf.set(QueryServices.MUTATE_BATCH_SIZE_ATTRIB, Integer.toString(3000)); + hbaseTestUtil.startMiniCluster(); + // establish url and quorum. Need to use PhoenixDriver and not PhoenixTestDriver + String zkQuorum = "localhost:" + hbaseTestUtil.getZkCluster().getClientPort(); + url = PhoenixRuntime.JDBC_PROTOCOL + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR + zkQuorum; + DriverManager.registerDriver(PhoenixDriver.INSTANCE); + } } @Test public void testUpdateCacheFrequencyWithAddAndDropTable() throws Exception { // Create connections 1 and 2 - Properties longRunningProps = new Properties(); // Must update config before starting server + Properties longRunningProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); // Must update config before starting server longRunningProps.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS); longRunningProps.put(QueryServices.DROP_METADATA_ATTRIB, Boolean.TRUE.toString()); @@ -136,7 +151,7 @@ public void testUpdateCacheFrequencyWithAddAndDropTable() throws Exception { @Test public void testTableSentWhenIndexStateChanges() throws Throwable { // Create connections 1 and 2 - Properties longRunningProps = new Properties(); // Must update config before starting server + Properties longRunningProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); // Must update config before starting server longRunningProps.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS); longRunningProps.put(QueryServices.DROP_METADATA_ATTRIB, Boolean.TRUE.toString()); @@ -154,14 +169,14 @@ public void testTableSentWhenIndexStateChanges() throws Throwable { String fullIndexName = SchemaUtil.getTableName(schemaName, indexName); conn1.createStatement().execute("CREATE TABLE " + fullTableName + "(k INTEGER PRIMARY KEY, v1 INTEGER, v2 INTEGER) COLUMN_ENCODED_BYTES = 0, STORE_NULLS=true"); conn1.createStatement().execute("CREATE INDEX " + indexName + " ON " + fullTableName + " (v1) INCLUDE (v2)"); - Table metaTable = conn2.unwrap(PhoenixConnection.class).getQueryServices().getTable(PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME_BYTES); + Table metaTable = conn2.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getTable(PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME_BYTES); IndexUtil.updateIndexState(fullIndexName, 0, metaTable, PIndexState.DISABLE); conn2.createStatement().execute("UPSERT INTO " + fullTableName + " VALUES(1,2,3)"); conn2.commit(); conn1.createStatement().execute("UPSERT INTO " + fullTableName + " VALUES(4,5,6)"); conn1.commit(); PTableKey key = new PTableKey(null,fullTableName); - PMetaData metaCache = conn1.unwrap(PhoenixConnection.class).getMetaDataCache(); + PMetaData metaCache = conn1.unwrap(PhoenixMonitoredConnection.class).getMetaDataCache(); PTable table = metaCache.getTableRef(key).getTable(); for (PTable index : table.getIndexes()) { assertEquals(PIndexState.DISABLE, index.getIndexState()); @@ -175,7 +190,7 @@ public void testTableSentWhenIndexStateChanges() throws Throwable { @Test public void testUpdateCacheFrequencyWithAddColumn() throws Exception { // Create connections 1 and 2 - Properties longRunningProps = new Properties(); // Must update config before starting server + Properties longRunningProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); // Must update config before starting server longRunningProps.put(HConstants.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY, ZKConnectionInfo.ZK_REGISTRY_NAME); Connection conn1 = DriverManager.getConnection(url, longRunningProps); Connection conn2 = DriverManager.getConnection(url, longRunningProps); @@ -221,7 +236,7 @@ public void testUpdateCacheFrequencyWithAddColumn() throws Exception { @Test public void testUpdateCacheFrequencyWithAddAndDropIndex() throws Exception { // Create connections 1 and 2 - Properties longRunningProps = new Properties(); + Properties longRunningProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); longRunningProps.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS); longRunningProps.put(HConstants.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY, ZKConnectionInfo.ZK_REGISTRY_NAME); @@ -273,7 +288,7 @@ public void testUpdateCacheFrequencyWithAddAndDropIndex() throws Exception { @Test public void testUpdateCacheFrequencyWithAddAndDropView() throws Exception { // Create connections 1 and 2 - Properties longRunningProps = new Properties(); + Properties longRunningProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); longRunningProps.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS); longRunningProps.put(HConstants.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY, ZKConnectionInfo.ZK_REGISTRY_NAME); @@ -321,7 +336,7 @@ public void testUpdateCacheFrequencyWithAddAndDropView() throws Exception { @Test public void testUpdateCacheFrequencyWithCreateTableAndViewOnDiffConns() throws Exception { // Create connections 1 and 2 - Properties longRunningProps = new Properties(); + Properties longRunningProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); longRunningProps.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS); longRunningProps.put(HConstants.CLIENT_CONNECTION_REGISTRY_IMPL_CONF_KEY, ZKConnectionInfo.ZK_REGISTRY_NAME); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeIT.java index ba22c0e844d..33361faf7fc 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeIT.java @@ -106,7 +106,6 @@ import org.apache.phoenix.util.UpgradeUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(NeedsOwnMiniClusterTest.class) public class UpgradeIT extends ParallelStatsDisabledIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeNamespaceIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeNamespaceIT.java index ecc41e9c725..47b41b80d50 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeNamespaceIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeNamespaceIT.java @@ -48,7 +48,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; - @Category(NeedsOwnMiniClusterTest.class) public class UpgradeNamespaceIT extends ParallelStatsDisabledIT { @Test diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpperLowerFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpperLowerFunctionIT.java index beaeb879814..9b30f78a158 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpperLowerFunctionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpperLowerFunctionIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +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; @@ -27,10 +28,10 @@ import java.sql.ResultSet; import java.sql.SQLException; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class UpperLowerFunctionIT extends ParallelStatsDisabledIT { private static String tableName = generateUniqueName(); @@ -39,7 +40,7 @@ public class UpperLowerFunctionIT extends ParallelStatsDisabledIT { @BeforeClass public static synchronized void init() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String ddl = "CREATE TABLE " + tableName + " (" + "id INTEGER PRIMARY KEY," + "first_name VARCHAR," @@ -57,7 +58,7 @@ public static synchronized void init() throws SQLException { @Test public void testWhereLower() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery(String.format( @@ -73,7 +74,7 @@ public void testWhereLower() throws SQLException { @Test public void testSelectLower() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery(String.format( @@ -89,7 +90,7 @@ public void testSelectLower() throws SQLException { @Test public void testWhereUpper() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery(String.format( @@ -105,7 +106,7 @@ public void testWhereUpper() throws SQLException { @Test public void testSelectUpper() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs; rs = conn.createStatement().executeQuery(String.format( diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertBigValuesIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertBigValuesIT.java index 1dd96796e83..2d638413795 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertBigValuesIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertBigValuesIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +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; @@ -32,10 +33,10 @@ import org.apache.phoenix.schema.types.PDataType; import org.apache.phoenix.schema.types.PLong; import org.apache.phoenix.schema.types.PSmallint; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.experimental.categories.Category; import org.apache.phoenix.thirdparty.com.google.common.collect.Lists; - @Category(ParallelStatsDisabledTest.class) public class UpsertBigValuesIT extends ParallelStatsDisabledIT { @@ -48,7 +49,7 @@ public void testIntegerPK() throws Exception { -2, -1, 0, 1, 2, Integer.MAX_VALUE - 1, Integer.MAX_VALUE}; String tableName = generateUniqueName(); ensureTableCreated(getUrl(), tableName,"PKIntValueTest"); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String upsert = "UPSERT INTO " + tableName + " VALUES(?)"; PreparedStatement stmt = conn.prepareStatement(upsert); @@ -135,7 +136,7 @@ public void testBigIntPK() throws Exception { long[] testNumbers = {Long.MIN_VALUE+1 , Long.MIN_VALUE+2 , -2L, -1L, 0L, 1L, 2L, Long.MAX_VALUE-1, Long.MAX_VALUE}; ensureTableCreated(getUrl(), tableName, "PKBigIntValueTest" ); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String upsert = "UPSERT INTO " + tableName + " VALUES(?)"; PreparedStatement stmt = conn.prepareStatement(upsert); @@ -219,7 +220,7 @@ public void testIntegerKV() throws Exception { int[] testNumbers = {Integer.MIN_VALUE, Integer.MIN_VALUE + 1, -2, -1, 0, 1, 2, Integer.MAX_VALUE - 1, Integer.MAX_VALUE}; ensureTableCreated(getUrl(), tableName, "KVIntValueTest" ); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String upsert = "UPSERT INTO " + tableName + " VALUES(?, ?)"; PreparedStatement stmt = conn.prepareStatement(upsert); @@ -303,7 +304,7 @@ public void testBigIntKV() throws Exception { long[] testNumbers = {Long.MIN_VALUE+1, Long.MIN_VALUE+2, -2L, -1L, 0L, 1L, 2L, Long.MAX_VALUE-1, Long.MAX_VALUE}; ensureTableCreated(getUrl(), tableName, "KVBigIntValueTest" ); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String upsert = "UPSERT INTO " + tableName + " VALUES(?,?)"; PreparedStatement stmt = conn.prepareStatement(upsert); @@ -405,7 +406,7 @@ private void testValues(boolean immutable, PDataType dataT String ddl = String.format("CREATE %s TABLE %s (K INTEGER PRIMARY KEY, V1 %s)", immutable ? "IMMUTABLE" : "", tableName, dataType.getSqlTypeName()); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute(ddl); String upsert = "UPSERT INTO " + tableName + " VALUES(?, ?)"; PreparedStatement stmt = conn.prepareStatement(upsert); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectAutoCommitIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectAutoCommitIT.java index 9dd30591739..c958764cb5f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectAutoCommitIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectAutoCommitIT.java @@ -20,6 +20,7 @@ import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.Admin; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.TestUtil; @@ -36,7 +37,6 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; - @Category(ParallelStatsDisabledTest.class) @RunWith(Parameterized.class) public class UpsertSelectAutoCommitIT extends ParallelStatsDisabledIT { @@ -54,7 +54,7 @@ public static synchronized Object[] data() { @Test public void testAutoCommitUpsertSelect() throws Exception { - Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); + Properties props = props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); Connection conn = DriverManager.getConnection(getUrl(), props); @@ -174,7 +174,7 @@ public void testDynamicUpsertSelect() throws Exception { @Test public void testUpsertSelectDoesntSeeUpsertedData() throws Exception { - Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); + Properties props = props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.MUTATE_BATCH_SIZE_BYTES_ATTRIB, Integer.toString(512)); props.setProperty(QueryServices.SCAN_CACHE_SIZE_ATTRIB, Integer.toString(3)); props.setProperty(QueryServices.SCAN_RESULT_CHUNK_SIZE, Integer.toString(3)); @@ -198,7 +198,7 @@ public void testUpsertSelectDoesntSeeUpsertedData() throws Exception { conn.prepareStatement("UPSERT INTO " + tableName + " SELECT NEXT VALUE FOR "+ tableName + "_seq, val FROM " + tableName); Admin admin = - driver.getConnectionQueryServices(getUrl(), TestUtil.TEST_PROPERTIES).getAdmin(); + driver.getConnectionQueryServices(getActiveUrl(), TestUtil.TEST_PROPERTIES).getAdmin(); for (int i=0; i<12; i++) { try { admin.split(TableName.valueOf(tableName)); @@ -214,13 +214,13 @@ public void testUpsertSelectDoesntSeeUpsertedData() throws Exception { @Test public void testMaxMutationSize() throws Exception { - Properties connectionProperties = new Properties(); + Properties connectionProperties = PropertiesUtil.deepCopy(TEST_PROPERTIES); connectionProperties.setProperty(QueryServices.MAX_MUTATION_SIZE_ATTRIB, "3"); connectionProperties.setProperty(QueryServices.MAX_MUTATION_SIZE_BYTES_ATTRIB, "50000"); connectionProperties.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); - PhoenixConnection connection = - (PhoenixConnection) DriverManager.getConnection(getUrl(), connectionProperties); + PhoenixMonitoredConnection connection = + (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), connectionProperties); connection.setAutoCommit(true); String fullTableName = generateUniqueName(); try (Statement stmt = connection.createStatement()) { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectIT.java index 347f4db0772..2d009833feb 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_OPEN_PHOENIX_CONNECTIONS; import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB; import static org.apache.phoenix.util.PhoenixRuntime.UPSERT_BATCH_SIZE_ATTRIB; @@ -72,7 +73,6 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; - @Category(ParallelStatsDisabledTest.class) @RunWith(Parameterized.class) public class UpsertSelectIT extends ParallelStatsDisabledIT { @@ -91,7 +91,11 @@ public static synchronized void doSetup() throws Exception { Long.toString(Long.MAX_VALUE)); props.put(QueryServices.TASK_HANDLING_INITIAL_DELAY_MS_ATTRIB, Long.toString(Long.MAX_VALUE)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } public UpsertSelectIT(String allowServerSideMutations) { @@ -316,7 +320,7 @@ public void testUpsertSelectEmptyPKColumn() throws Exception { String aTable = initATableValues(tenantId, getDefaultSplits(tenantId)); String ptsdbTable = generateUniqueName(); ensureTableCreated(getUrl(), ptsdbTable, PTSDB_NAME); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); String upsert; @@ -495,7 +499,7 @@ private void testUpsertSelectForAgg(boolean autoCommit) throws Exception { String aTable = initATableValues(tenantId, getDefaultSplits(tenantId)); String ptsdbTable = generateUniqueName(); ensureTableCreated(getUrl(), ptsdbTable, PTSDB_NAME); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { @@ -573,7 +577,7 @@ public void testUpsertSelectLongToInt() throws Exception { PInteger.INSTANCE.toBytes(4)}; String tableName = generateUniqueName(); ensureTableCreated(getUrl(), tableName, "IntKeyTest", splits, null); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); String upsert = "UPSERT INTO " + tableName + " VALUES(1)"; @@ -614,7 +618,7 @@ public void testUpsertSelectRunOnServer() throws Exception { String tableName = generateUniqueName(); createTestTable(getUrl(), "create table " + tableName + " (i integer not null primary key desc, j integer)", splits, null); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); ResultSet rs; @@ -683,7 +687,7 @@ public void testUpsertSelectOnDescToAsc() throws Exception { String tableName = generateUniqueName(); createTestTable(getUrl(), "create table " + tableName + " (i integer not null primary key desc, j integer)", splits, null); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); ResultSet rs; @@ -728,7 +732,7 @@ public void testUpsertSelectRowKeyMutationOnSplitedTable() throws Exception { PInteger.INSTANCE.toBytes(4)}; String tableName = generateUniqueName(); ensureTableCreated(getUrl(), tableName, "IntKeyTest", splits, null, null); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); int rowsInserted; @@ -772,7 +776,7 @@ public void testUpsertSelectRowKeyMutationOnSplitedTable() throws Exception { @Test public void testUpsertSelectWithLimit() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); String tableName = generateUniqueName(); @@ -848,7 +852,7 @@ public void testUpsertSelectWithLimit() throws Exception { @Test public void testUpsertSelectWithOrderBy() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); props.setProperty(QueryServices.AUTO_COMMIT_ATTRIB, "true"); @@ -908,7 +912,7 @@ public void testUpsertSelectWithOrderBy() throws Exception { @Test public void testUpsertSelectWithSequence() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); String t1 = generateUniqueName(); @@ -1026,7 +1030,7 @@ public void testUpsertSelectWithRowtimeStampColumn() throws Exception { String t1 = generateUniqueName(); String t2 = generateUniqueName(); String t3 = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.execute("CREATE TABLE " + t1 + " (PK1 VARCHAR NOT NULL, PK2 DATE NOT NULL, KV1 VARCHAR CONSTRAINT PK " + @@ -1042,7 +1046,7 @@ public void testUpsertSelectWithRowtimeStampColumn() throws Exception { // The timestamp of the put will be the value of the row_timestamp column. long rowTimestamp = EnvironmentEdgeManager.currentTimeMillis(); Date rowTimestampDate = new Date(rowTimestamp); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); try (Connection conn = DriverManager.getConnection(getUrl(), props); @@ -1057,7 +1061,7 @@ public void testUpsertSelectWithRowtimeStampColumn() throws Exception { // Upsert select data into table T2. The connection needs to be at a timestamp beyond the // row timestamp. Otherwise it won't see the data from table T1. - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.executeUpdate("UPSERT INTO " + t2 + " SELECT * FROM " + t1); conn.commit(); @@ -1091,7 +1095,7 @@ public void testUpsertSelectWithRowtimeStampColumn() throws Exception { // Upsert select data into table T3. The connection needs to be at a timestamp beyond the // row timestamp. Otherwise it won't see the data from table T1. - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.executeUpdate("UPSERT INTO " + t3 + " SELECT * FROM " + t1); conn.commit(); @@ -1125,7 +1129,7 @@ public void testUpsertSelectWithRowtimeStampColumn() throws Exception { @Test public void testUpsertSelectSameTableWithRowTimestampColumn() throws Exception { String tableName = generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); try (Connection conn = DriverManager.getConnection(getUrl(), props); @@ -1178,7 +1182,7 @@ public void testAutomaticallySettingRowtimestamp() throws Exception { String table1 = generateUniqueName(); String table2 = generateUniqueName(); String table3 = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.execute("CREATE TABLE " + table1 + " (T1PK1 VARCHAR NOT NULL, T1PK2 DATE NOT NULL, T1KV1 VARCHAR, T1KV2 VARCHAR " + @@ -1191,7 +1195,7 @@ public void testAutomaticallySettingRowtimestamp() throws Exception { " CONSTRAINT PK PRIMARY KEY(T3PK1, T3PK2 DESC ROW_TIMESTAMP)) "); } long startTime = EnvironmentEdgeManager.currentTimeMillis(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); try (Connection conn = DriverManager.getConnection(getUrl(), props); @@ -1279,7 +1283,7 @@ public void testAutomaticallySettingRowtimestamp() throws Exception { public void testUpsertSelectAutoCommitWithRowTimestampColumn() throws Exception { String tableName1 = generateUniqueName(); String tableName2 = generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); try (Connection conn = DriverManager.getConnection(getUrl(), props); @@ -1372,7 +1376,7 @@ public void testRowTimestampColWithViewsIndexesAndSaltedTables() throws Exceptio String baseTableIdx = generateUniqueName(); String tenantViewIdx = generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); try (Connection conn = DriverManager.getConnection(getUrl(), props); @@ -1614,7 +1618,7 @@ public void testRowTimestampColWithViewsIndexesAndSaltedTables() throws Exceptio public void testDisallowNegativeValuesForRowTsColumn() throws Exception { String tableName = generateUniqueName(); String tableName2 = generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); try (Connection conn = DriverManager.getConnection(getUrl(), props); @@ -1645,7 +1649,7 @@ public void testDisallowNegativeValuesForRowTsColumn() throws Exception { @Test public void testUpsertSelectWithFixedWidthNullByteSizeArray() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); String t1 = generateUniqueName(); @@ -1719,7 +1723,7 @@ public void testUpsertSelectWithMultiByteCharsAutoCommit() throws Exception { } private void testUpsertSelectWithMultiByteChars(boolean autoCommit) throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); String t1 = generateUniqueName(); @@ -1818,7 +1822,7 @@ public void testParallelUpsertSelect() throws Exception { public void testLongCodecUsedForRowTimestamp() throws Exception { String tableName = generateUniqueName(); String indexName = generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); try (Connection conn = DriverManager.getConnection(getUrl(), props); @@ -1890,7 +1894,7 @@ public void testLongCodecUsedForRowTimestamp() throws Exception { public void testLengthLimitedVarchar() throws Exception { String tableName1 = generateUniqueName(); String tableName2 = generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); try (Connection conn = DriverManager.getConnection(getUrl(), props); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectWithRegionMovesIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectWithRegionMovesIT.java index b89a20bcc6f..6ec4d5f7b8b 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectWithRegionMovesIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectWithRegionMovesIT.java @@ -57,6 +57,7 @@ import java.util.Map; import java.util.Properties; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB; import static org.apache.phoenix.util.PhoenixRuntime.UPSERT_BATCH_SIZE_ATTRIB; import static org.apache.phoenix.util.TestUtil.A_VALUE; @@ -74,7 +75,6 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; - @Category(NeedsOwnMiniClusterTest.class) @RunWith(Parameterized.class) public class UpsertSelectWithRegionMovesIT extends ParallelStatsDisabledWithRegionMovesIT { @@ -98,7 +98,11 @@ public static synchronized void doSetup() throws Exception { props.put(HConstants.HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY, String.valueOf(1)); props.put(QueryServices.PHOENIX_POST_DUMMY_PROCESS, TestScanningResultPostDummyResultCaller.class.getName()); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } public UpsertSelectWithRegionMovesIT(String allowServerSideMutations) { @@ -322,7 +326,7 @@ public void testUpsertSelectEmptyPKColumn() throws Exception { String ptsdbTable = generateUniqueName(); TABLE_NAMES.add(ptsdbTable); ensureTableCreated(getUrl(), ptsdbTable, PTSDB_NAME); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); String upsert; @@ -520,7 +524,7 @@ private void testUpsertSelectForAgg(boolean autoCommit) throws Exception { TABLE_NAMES.add(aTable); TABLE_NAMES.add(ptsdbTable); ensureTableCreated(getUrl(), ptsdbTable, PTSDB_NAME); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { @@ -601,7 +605,7 @@ public void testUpsertSelectLongToInt() throws Exception { String tableName = generateUniqueName(); TABLE_NAMES.add(tableName); ensureTableCreated(getUrl(), tableName, "IntKeyTest", splits, null); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); String upsert = "UPSERT INTO " + tableName + " VALUES(1)"; @@ -645,7 +649,7 @@ public void testUpsertSelectRunOnServer() throws Exception { TABLE_NAMES.add(tableName); createTestTable(getUrl(), "create table " + tableName + " (i integer not null primary key desc, j integer)", splits, null); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); ResultSet rs; @@ -718,7 +722,7 @@ public void testUpsertSelectOnDescToAsc() throws Exception { TABLE_NAMES.add(tableName); createTestTable(getUrl(), "create table " + tableName + " (i integer not null primary key desc, j integer)", splits, null); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); ResultSet rs; @@ -765,7 +769,7 @@ public void testUpsertSelectRowKeyMutationOnSplitedTable() throws Exception { String tableName = generateUniqueName(); TABLE_NAMES.add(tableName); ensureTableCreated(getUrl(), tableName, "IntKeyTest", splits, null, null); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); int rowsInserted; @@ -811,7 +815,7 @@ public void testUpsertSelectRowKeyMutationOnSplitedTable() throws Exception { @Test public void testUpsertSelectWithLimit() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); String tableName = generateUniqueName(); @@ -892,7 +896,7 @@ public void testUpsertSelectWithLimit() throws Exception { @Test public void testUpsertSelectWithSequence() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); String t1 = generateUniqueName(); @@ -1027,7 +1031,7 @@ public void testUpsertSelectWithRowtimeStampColumn() throws Exception { TABLE_NAMES.add(t1); TABLE_NAMES.add(t2); TABLE_NAMES.add(t3); - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.execute("CREATE TABLE " + t1 + " (PK1 VARCHAR NOT NULL, PK2 DATE NOT NULL, KV1 VARCHAR CONSTRAINT PK " + @@ -1043,7 +1047,7 @@ public void testUpsertSelectWithRowtimeStampColumn() throws Exception { // The timestamp of the put will be the value of the row_timestamp column. long rowTimestamp = EnvironmentEdgeManager.currentTimeMillis(); Date rowTimestampDate = new Date(rowTimestamp); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); try (Connection conn = DriverManager.getConnection(getUrl(), props); @@ -1058,7 +1062,7 @@ public void testUpsertSelectWithRowtimeStampColumn() throws Exception { // Upsert select data into table T2. The connection needs to be at a timestamp beyond the // row timestamp. Otherwise it won't see the data from table T1. - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.executeUpdate("UPSERT INTO " + t2 + " SELECT * FROM " + t1); conn.commit(); @@ -1092,7 +1096,7 @@ public void testUpsertSelectWithRowtimeStampColumn() throws Exception { // Upsert select data into table T3. The connection needs to be at a timestamp beyond the // row timestamp. Otherwise it won't see the data from table T1. - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.executeUpdate("UPSERT INTO " + t3 + " SELECT * FROM " + t1); conn.commit(); @@ -1127,7 +1131,7 @@ public void testUpsertSelectWithRowtimeStampColumn() throws Exception { public void testUpsertSelectSameTableWithRowTimestampColumn() throws Exception { String tableName = generateUniqueName(); TABLE_NAMES.add(tableName); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); try (Connection conn = DriverManager.getConnection(getUrl(), props); @@ -1183,7 +1187,7 @@ public void testAutomaticallySettingRowtimestamp() throws Exception { TABLE_NAMES.add(table1); TABLE_NAMES.add(table2); TABLE_NAMES.add(table3); - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { stmt.execute("CREATE TABLE " + table1 + " (T1PK1 VARCHAR NOT NULL, T1PK2 DATE NOT NULL, T1KV1 VARCHAR, T1KV2 VARCHAR " + @@ -1196,7 +1200,7 @@ public void testAutomaticallySettingRowtimestamp() throws Exception { " CONSTRAINT PK PRIMARY KEY(T3PK1, T3PK2 DESC ROW_TIMESTAMP)) "); } long startTime = EnvironmentEdgeManager.currentTimeMillis(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); try (Connection conn = DriverManager.getConnection(getUrl(), props); @@ -1292,7 +1296,7 @@ public void testUpsertSelectAutoCommitWithRowTimestampColumn() throws Exception String tableName2 = generateUniqueName(); TABLE_NAMES.add(tableName1); TABLE_NAMES.add(tableName2); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); try (Connection conn = DriverManager.getConnection(getUrl(), props); @@ -1390,7 +1394,7 @@ public void testRowTimestampColWithViewsIndexesAndSaltedTables() throws Exceptio TABLE_NAMES.add(baseTableIdx); TABLE_NAMES.add("_IDX_" + baseTable); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); try (Connection conn = DriverManager.getConnection(getUrl(), props); @@ -1665,7 +1669,7 @@ public void testDisallowNegativeValuesForRowTsColumn() throws Exception { String tableName2 = generateUniqueName(); TABLE_NAMES.add(tableName); TABLE_NAMES.add(tableName2); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); try (Connection conn = DriverManager.getConnection(getUrl(), props); @@ -1696,7 +1700,7 @@ public void testDisallowNegativeValuesForRowTsColumn() throws Exception { @Test public void testUpsertSelectWithFixedWidthNullByteSizeArray() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); String t1 = generateUniqueName(); @@ -1772,7 +1776,7 @@ public void testUpsertSelectWithMultiByteCharsAutoCommit() throws Exception { } private void testUpsertSelectWithMultiByteChars(boolean autoCommit) throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); String t1 = generateUniqueName(); @@ -1877,7 +1881,7 @@ public void testLongCodecUsedForRowTimestamp() throws Exception { String indexName = generateUniqueName(); TABLE_NAMES.add(tableName); TABLE_NAMES.add(indexName); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); try (Connection conn = DriverManager.getConnection(getUrl(), props); @@ -1959,7 +1963,7 @@ public void testLengthLimitedVarchar() throws Exception { String tableName2 = generateUniqueName(); TABLE_NAMES.add(tableName1); TABLE_NAMES.add(tableName2); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, allowServerSideMutations); try (Connection conn = DriverManager.getConnection(getUrl(), props); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertValuesIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertValuesIT.java index 2c3b4f9f1e7..c4e730a6dc9 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertValuesIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertValuesIT.java @@ -21,6 +21,7 @@ import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB; import static org.apache.phoenix.util.TestUtil.closeStatement; import static org.apache.phoenix.util.TestUtil.closeStmtAndConn; +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.assertNull; @@ -50,6 +51,7 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.monitoring.MetricType; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.SequenceNotFoundException; @@ -64,14 +66,13 @@ import org.junit.experimental.categories.Category; import org.junit.function.ThrowingRunnable; - @Category(ParallelStatsDisabledTest.class) public class UpsertValuesIT extends ParallelStatsDisabledIT { @Test public void testGroupByWithLimitOverRowKey() throws Exception { String tableName = generateUniqueName(); ensureTableCreated(getUrl(), tableName, TestUtil.PTSDB_NAME, null, null, null); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); conn.setAutoCommit(true); PreparedStatement stmt = conn.prepareStatement("UPSERT INTO " + tableName + " (inst,host,\"DATE\") VALUES(?,'b',CURRENT_DATE())"); @@ -106,7 +107,7 @@ public void testUpsertDateValues() throws Exception { String tableName = generateUniqueName(); Date now = new Date(EnvironmentEdgeManager.currentTimeMillis()); ensureTableCreated(getUrl(), tableName, TestUtil.PTSDB_NAME, null, null, null); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String dateString = "1999-01-01 02:00:00"; PreparedStatement upsertStmt = conn.prepareStatement("upsert into " + tableName + "(inst,host,\"DATE\") values('aaa','bbb',to_date('" + dateString + "'))"); @@ -133,7 +134,7 @@ public void testUpsertDateValues() throws Exception { public void testUpsertValuesWithExpression() throws Exception { String tableName = generateUniqueName(); ensureTableCreated(getUrl(), tableName, "IntKeyTest", null, null, null); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String upsert = "UPSERT INTO " + tableName + " VALUES(-1)"; PreparedStatement upsertStmt = conn.prepareStatement(upsert); @@ -158,7 +159,7 @@ public void testUpsertValuesWithExpression() throws Exception { @Test public void testUpsertValuesWithDate() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); String tableName = generateUniqueName(); conn.createStatement().execute("create table " + tableName + " (k VARCHAR not null primary key,\"DATE\" DATE)"); @@ -178,7 +179,7 @@ public void testUpsertValuesWithDate() throws Exception { @Test public void testUpsertValuesWithDescDecimal() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); String tableName = generateUniqueName(); Connection conn = DriverManager.getConnection(getUrl(), props); conn.createStatement().execute("create table " + tableName + " (k DECIMAL(12,3) NOT NULL PRIMARY KEY DESC)"); @@ -197,7 +198,7 @@ public void testUpsertValuesWithDescDecimal() throws Exception { @Test public void testUpsertRandomValues() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); String tableName = generateUniqueName(); Connection conn = DriverManager.getConnection(getUrl(), props); conn.createStatement().execute("create table " + tableName + " (k UNSIGNED_DOUBLE not null primary key, v1 UNSIGNED_DOUBLE, v2 UNSIGNED_DOUBLE, v3 UNSIGNED_DOUBLE, v4 UNSIGNED_DOUBLE)"); @@ -228,7 +229,7 @@ public void testUpsertRandomValues() throws Exception { @Test public void testUpsertVarCharWithMaxLength() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); String tableName = generateUniqueName(); Connection conn = DriverManager.getConnection(getUrl(), props); conn.createStatement().execute("create table " + tableName + " (mac_md5 VARCHAR not null primary key,raw_mac VARCHAR)"); @@ -261,7 +262,7 @@ public void testUpsertVarCharWithMaxLength() throws Exception { @Test public void testUpsertValuesWithDescExpression() throws Exception { String tableName = generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); conn.createStatement().execute("create table " + tableName + " (k VARCHAR not null primary key desc)"); conn.close(); @@ -281,7 +282,7 @@ public void testUpsertValuesWithDescExpression() throws Exception { @Test public void testUpsertValuesWithMoreValuesThanNumColsInTable() throws Exception { String tableName = generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = null; Statement stmt = null; try { @@ -307,7 +308,7 @@ public void testUpsertValuesWithMoreValuesThanNumColsInTable() throws Exception @Test public void testTimestampSerializedAndDeserializedCorrectly() throws Exception { String tableName = generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = null; PreparedStatement stmt = null; try { @@ -344,7 +345,7 @@ public void testTimestampSerializedAndDeserializedCorrectly() throws Exception { @Test public void testTimestampAddSubtractArithmetic() throws Exception { String tableName = generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = null; PreparedStatement stmt = null; try { @@ -435,7 +436,7 @@ public void testTimestampAddSubtractArithmetic() throws Exception { @Test public void testUpsertIntoFloat() throws Exception { String tableName = generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = null; PreparedStatement stmt = null; try { @@ -469,7 +470,7 @@ public void testUpsertIntoFloat() throws Exception { private void testBatchedUpsert(boolean autocommit) throws Exception { String tableName = generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(REQUEST_METRIC_ATTRIB, "true"); props.setProperty(QueryServices.COLLECT_REQUEST_LEVEL_METRICS, "true"); Connection conn = null; @@ -499,7 +500,7 @@ private void testBatchedUpsert(boolean autocommit) throws Exception { if (!autocommit) { conn.commit(); } - PhoenixConnection pConn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pConn = conn.unwrap(PhoenixMonitoredConnection.class); Map> mutationMetrics = pConn.getMutationMetrics(); Assert.assertEquals(3, (long) mutationMetrics.get(tableName).get(MetricType.MUTATION_BATCH_SIZE)); Assert.assertEquals(3, (long) mutationMetrics.get(tableName).get(MetricType.UPSERT_MUTATION_SQL_COUNTER)); @@ -604,7 +605,7 @@ public void testBatchedUpsertAutoCommit() throws Exception { @Test public void testBatchedUpsertMultipleBatches() throws Exception { String tableName = generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { conn.createStatement().execute("create table " + tableName + " (k varchar primary key, v integer)"); PreparedStatement pstmt = conn.prepareStatement("upsert into " + tableName + " values (?, ?)"); @@ -629,7 +630,7 @@ public void testBatchedUpsertMultipleBatches() throws Exception { private void testBatchRollback(boolean autocommit) throws Exception { String tableName = generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { conn.createStatement().execute("create table " + tableName + " (k varchar primary key, v integer)"); conn.setAutoCommit(autocommit); @@ -662,7 +663,7 @@ public void testBatchNoRollbackWithAutoCommit() throws Exception { @Test public void testDQLFailsInBatch() throws Exception { String tableName = generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { conn.createStatement().execute("create table " + tableName + " (k varchar primary key, v integer)"); Statement stmt = conn.createStatement(); @@ -680,7 +681,7 @@ private static Date toDate(String dateString) { @Test public void testUpsertDateIntoDescUnsignedDate() throws Exception { String tableName = generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = null; PreparedStatement stmt = null; try { @@ -718,7 +719,7 @@ public void testUpsertDateIntoDescUnsignedDate() throws Exception { @Test public void testUpsertDateString() throws Exception { String tableName = generateUniqueName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = null; PreparedStatement stmt = null; try { @@ -765,14 +766,14 @@ public void testUpsertDateString() throws Exception { @Test public void testAutoCastLongToBigDecimal() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute("CREATE TABLE LONG_BUG (NAME VARCHAR PRIMARY KEY, AMOUNT DECIMAL)"); } - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute("UPSERT INTO LONG_BUG (NAME, AMOUNT) VALUES('HELLO1', -50000)"); conn.commit(); } - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { ResultSet rs = conn.createStatement().executeQuery("SELECT NAME, AMOUNT FROM LONG_BUG"); assertTrue(rs.next()); assertEquals("HELLO1", rs.getString(1)); @@ -789,7 +790,7 @@ public void testColumnQualifierForUpsertedValues() throws Exception { + " (" + " K varchar primary key," + " CF1.V1 varchar, CF2.V2 VARCHAR, CF2.V3 VARCHAR)"; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute(ddl); } String dml = "UPSERT INTO " + fullTableName + " VALUES (?, ?, ?, ?)"; @@ -803,8 +804,8 @@ public void testColumnQualifierForUpsertedValues() throws Exception { conn.commit(); } // Issue a raw hbase scan and assert that key values have the expected column qualifiers. - try (Connection conn = DriverManager.getConnection(getUrl())) { - Table table = conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(Bytes.toBytes(fullTableName)); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { + Table table = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getTable(Bytes.toBytes(fullTableName)); ResultScanner scanner = table.getScanner(new Scan()); Result next = scanner.next(); assertTrue(next.containsColumn(Bytes.toBytes("CF1"), PInteger.INSTANCE.toBytes(1))); @@ -816,7 +817,7 @@ public void testColumnQualifierForUpsertedValues() throws Exception { @Test public void testUpsertValueWithDiffSequenceAndConnections() throws Exception { String tableName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.setAutoCommit(true); PreparedStatement createTableStatement = conn.prepareStatement(String.format("CREATE TABLE IF NOT EXISTS " + "%s (SERVICE VARCHAR NOT NULL, SEQUENCE_NUMBER BIGINT NOT NULL , " + @@ -841,8 +842,7 @@ private void testTenantSequenceUpsertWithGlobalConnection(String tableName) thro "IF NOT EXISTS %s", sequenceName)); createSequenceStatement.execute(); } - - try (Connection tenantConn = DriverManager.getConnection(getUrl())) { + try (Connection tenantConn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { tenantConn.setAutoCommit(true); Statement executeUpdateStatement = tenantConn.createStatement(); try { @@ -904,8 +904,7 @@ private void testTenantSequenceUpsertWithSameTenantConnection(String tableName) private void testGlobalSequenceUpsertWithGlobalConnection(String tableName) throws Exception { String sequenceName = generateUniqueSequenceName(); - - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.setAutoCommit(true); PreparedStatement createSequenceStatement = conn.prepareStatement(String.format("CREATE SEQUENCE " + "IF NOT EXISTS %s", sequenceName)); @@ -926,8 +925,7 @@ private void testGlobalSequenceUpsertWithGlobalConnection(String tableName) thro private void testGlobalSequenceUpsertWithTenantConnection(String tableName) throws Exception { String sequenceName = generateUniqueSequenceName(); - - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.setAutoCommit(true); PreparedStatement createSequenceStatement = conn.prepareStatement(String.format("CREATE SEQUENCE " + "IF NOT EXISTS %s", sequenceName)); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertWithSCNIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertWithSCNIT.java index 8369d2eb543..0a2a905e115 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertWithSCNIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertWithSCNIT.java @@ -18,6 +18,7 @@ package org.apache.phoenix.end2end; import org.apache.phoenix.exception.SQLExceptionCode; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -30,11 +31,11 @@ import java.sql.SQLException; import java.util.Properties; +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; - @Category(ParallelStatsDisabledTest.class) public class UpsertWithSCNIT extends ParallelStatsDisabledIT { @@ -56,7 +57,7 @@ private void helpTestUpsertWithSCNIT(boolean rowColumn, boolean txTable, + (rowColumn? "CREATED_DATE ROW_TIMESTAMP, ":"") + "METRIC_ID)) " + "IMMUTABLE_ROWS=" + (mutable? "false" : "true" ) + (txTable ? ", TRANSACTION_PROVIDER='OMID',TRANSACTIONAL=true":""); - props = new Properties(); + props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); conn.createStatement().execute(createTable); @@ -92,7 +93,7 @@ public void testUpsertOnSCNSetMutTableWithoutIdx() throws Exception { helpTestUpsertWithSCNIT(false, false, true, false, false); prep.executeUpdate(); - props = new Properties(); + props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(),props); ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM "+tableName); assertTrue(rs.next()); @@ -106,7 +107,7 @@ public void testUpsertOnSCNSetTable() throws Exception { helpTestUpsertWithSCNIT(false, false, false, false, false); prep.executeUpdate(); - props = new Properties(); + props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(),props); ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM "+tableName); assertTrue(rs.next()); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UseSchemaIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UseSchemaIT.java index d4dc1d5104a..a21ed328a29 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UseSchemaIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UseSchemaIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -38,11 +39,11 @@ import org.apache.phoenix.query.QueryConstants; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.types.PVarchar; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.util.TestUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class UseSchemaIT extends ParallelStatsDisabledIT { @@ -59,7 +60,7 @@ public void testUseSchemaCaseSensitive() throws Exception { } public void testUseSchema(String schema) throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.toString(true)); Connection conn = DriverManager.getConnection(getUrl(), props); String ddl = "CREATE SCHEMA IF NOT EXISTS "+schema; @@ -91,7 +92,7 @@ public void testUseSchema(String schema) throws Exception { @Test public void testSchemaInJdbcUrl() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); String schema = generateUniqueName(); props.setProperty(QueryServices.SCHEMA_ATTRIB, schema); props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.toString(true)); @@ -124,7 +125,7 @@ public void testSchemaInJdbcUrl() throws Exception { @Test public void testSequences() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); String schema = generateUniqueName(); props.setProperty(QueryServices.SCHEMA_ATTRIB, schema); props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.toString(true)); @@ -162,13 +163,13 @@ public void testSequences() throws Exception { @Test public void testMappedView() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); String schema = generateUniqueName(); String tableName = generateUniqueName(); String fullTablename = schema + QueryConstants.NAME_SEPARATOR + tableName; props.setProperty(QueryServices.SCHEMA_ATTRIB, schema); Connection conn = DriverManager.getConnection(getUrl(), props); - Admin admin = driver.getConnectionQueryServices(getUrl(), TestUtil.TEST_PROPERTIES).getAdmin(); + Admin admin = driver.getConnectionQueryServices(getActiveUrl(), TestUtil.TEST_PROPERTIES).getAdmin(); admin.createNamespace(NamespaceDescriptor.create(schema).build()); admin.createTable(TableDescriptorBuilder.newBuilder(TableName.valueOf(fullTablename)). setColumnFamily(ColumnFamilyDescriptorBuilder.of(QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES)).build()); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/VarBinaryEncoded1IT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/VarBinaryEncoded1IT.java index 28e13ec6760..d12bb443486 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/VarBinaryEncoded1IT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/VarBinaryEncoded1IT.java @@ -38,7 +38,6 @@ import org.apache.phoenix.util.PropertiesUtil; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; - @Category(ParallelStatsDisabledTest.class) @RunWith(Parameterized.class) public class VarBinaryEncoded1IT extends ParallelStatsDisabledIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/VarBinaryEncoded2IT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/VarBinaryEncoded2IT.java index bfe97bd9f06..e14187c3a62 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/VarBinaryEncoded2IT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/VarBinaryEncoded2IT.java @@ -40,7 +40,6 @@ import org.apache.phoenix.util.PropertiesUtil; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; - @Category(ParallelStatsDisabledTest.class) @RunWith(Parameterized.class) public class VarBinaryEncoded2IT extends ParallelStatsDisabledIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/VariableLengthPKIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/VariableLengthPKIT.java index 8497fe0e791..54f35cf666f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/VariableLengthPKIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/VariableLengthPKIT.java @@ -47,7 +47,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsDisabledTest.class) public class VariableLengthPKIT extends ParallelStatsDisabledIT { private static final String DS1 = "1970-01-01 00:58:00"; @@ -1931,12 +1930,12 @@ public void testLTrimFunction() throws Exception { public void testSubstrFunctionOnRowKeyInWhere() throws Exception { String substrTestTableName = generateUniqueName(); String url = getUrl(); - Connection conn = DriverManager.getConnection(url); + Connection conn = DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute("CREATE TABLE "+substrTestTableName+" (s1 varchar not null, s2 varchar not null constraint pk primary key(s1,s2))"); conn.close(); url = getUrl(); - conn = DriverManager.getConnection(url); + conn = DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute("UPSERT INTO "+substrTestTableName+" VALUES('abc','a')"); conn.createStatement().execute("UPSERT INTO "+substrTestTableName+" VALUES('abcd','b')"); conn.createStatement().execute("UPSERT INTO "+substrTestTableName+" VALUES('abce','c')"); @@ -1945,7 +1944,7 @@ public void testSubstrFunctionOnRowKeyInWhere() throws Exception { conn.close(); url = getUrl(); - conn = DriverManager.getConnection(url); + conn = DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery("SELECT s1 from "+substrTestTableName+" where substr(s1,1,4) = 'abcd'"); assertTrue(rs.next()); assertEquals("abcd",rs.getString(1)); @@ -1958,12 +1957,12 @@ public void testSubstrFunctionOnRowKeyInWhere() throws Exception { public void testRTrimFunctionOnRowKeyInWhere() throws Exception { String substrTestTableName = generateUniqueName(); String url = getUrl(); - Connection conn = DriverManager.getConnection(url); + Connection conn = DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute("CREATE TABLE "+substrTestTableName+" (s1 varchar not null, s2 varchar not null constraint pk primary key(s1,s2))"); conn.close(); url = getUrl(); - conn = DriverManager.getConnection(url); + conn = DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute("UPSERT INTO "+substrTestTableName+" VALUES('abc','a')"); conn.createStatement().execute("UPSERT INTO "+substrTestTableName+" VALUES('abcd','b')"); conn.createStatement().execute("UPSERT INTO "+substrTestTableName+" VALUES('abcd ','c')"); @@ -1974,7 +1973,7 @@ public void testRTrimFunctionOnRowKeyInWhere() throws Exception { conn.close(); url = getUrl(); - conn = DriverManager.getConnection(url); + conn = DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery("SELECT s1 from "+substrTestTableName+" where rtrim(s1) = 'abcd'"); assertTrue(rs.next()); assertEquals("abcd",rs.getString(1)); @@ -1989,12 +1988,12 @@ public void testRTrimFunctionOnRowKeyInWhere() throws Exception { public void testLikeFunctionOnRowKeyInWhere() throws Exception { String substrTestTableName = generateUniqueName(); String url = getUrl(); - Connection conn = DriverManager.getConnection(url); + Connection conn = DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute("CREATE TABLE "+substrTestTableName+" (s1 varchar not null, s2 varchar not null constraint pk primary key(s1,s2))"); conn.close(); url = getUrl(); - conn = DriverManager.getConnection(url); + conn = DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES)); conn.createStatement().execute("UPSERT INTO "+substrTestTableName+" VALUES('abc','a')"); conn.createStatement().execute("UPSERT INTO "+substrTestTableName+" VALUES('abcd','b')"); conn.createStatement().execute("UPSERT INTO "+substrTestTableName+" VALUES('abcd-','c')"); @@ -2004,7 +2003,7 @@ public void testLikeFunctionOnRowKeyInWhere() throws Exception { conn.close(); url = getUrl(); - conn = DriverManager.getConnection(url); + conn = DriverManager.getConnection(url, PropertiesUtil.deepCopy(TEST_PROPERTIES)); ResultSet rs = conn.createStatement().executeQuery("SELECT s1 from "+substrTestTableName+" where s1 like 'abcd%1'"); assertTrue(rs.next()); assertEquals("abcd-1",rs.getString(1)); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewConcurrencyAndFailureIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewConcurrencyAndFailureIT.java index 22df710bc12..029718fad44 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewConcurrencyAndFailureIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewConcurrencyAndFailureIT.java @@ -21,6 +21,7 @@ import static org.apache.phoenix.coprocessor.PhoenixMetaDataCoprocessorHost .PHOENIX_META_DATA_COPROCESSOR_CONF_KEY; import static org.apache.phoenix.exception.SQLExceptionCode.CANNOT_MUTATE_TABLE; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -58,6 +59,7 @@ import org.apache.phoenix.exception.PhoenixIOException; import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.ConcurrentTableMutationException; import org.apache.phoenix.schema.PTable; @@ -135,8 +137,14 @@ public static synchronized void doSetup() throws Exception { serverProps.put(PHOENIX_META_DATA_COPROCESSOR_CONF_KEY, TestMetaDataRegionObserver.class.getName()); serverProps.put("hbase.coprocessor.abortonerror", "false"); - setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), - ReadOnlyProps.EMPTY_PROPS); + serverProps.put(QueryServices.TRANSACTIONS_ENABLED, Boolean.TRUE.toString()); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(serverProps.entrySet().iterator()), + ReadOnlyProps.EMPTY_PROPS); + } else { + setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), + ReadOnlyProps.EMPTY_PROPS); + } // Split SYSTEM.CATALOG once after the mini-cluster is started if (splitSystemCatalog) { // splitSystemCatalog is incompatible with the balancer chore @@ -157,8 +165,8 @@ public void cleanup() throws Exception { @Test public void testChildViewCreationFails() throws Exception { - try (PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl()); - Statement stmt = conn.createStatement()) { + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Statement stmt = conn.createStatement()) { String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); @@ -188,8 +196,15 @@ public void testChildViewCreationFails() throws Exception { try { conn.getTableNoCache(failingViewName); fail(); - } catch (TableNotFoundException ignored) { + } catch (Exception e) { + if (e instanceof SQLException) { + if (e.getCause() instanceof TableNotFoundException) { + //Expected in case of HA Enabled + } + } else if(e instanceof TableNotFoundException) { + //eat the exception, which is what we expect } + } // we should be able to load the table conn.getTableNoCache(fullTableName); @@ -200,7 +215,7 @@ public void testChildViewCreationFails() throws Exception { @Test public void testConcurrentViewCreationAndTableDrop() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); @@ -259,7 +274,7 @@ public Thread newThread(Runnable r) { @Test public void testChildLinkCreationFailThrowsException() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); @@ -291,7 +306,7 @@ public void testChildLinkCreationFailThrowsException() throws Exception { @Test public void testConcurrentAddSameColumnDifferentType() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); @@ -378,12 +393,12 @@ public void testConcurrentAddSameColumnDifferentTypeTenantView() + " (v2 VARCHAR) AS SELECT * FROM " + fullTableName + " WHERE k = 6"; - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { // create a multi-tenant base table stmt.execute(tableDdl); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); try (Connection tenantConn = DriverManager.getConnection(getUrl(), props); @@ -443,7 +458,7 @@ public Thread newThread(Runnable r) { @Test public void testConcurrentAddDifferentColumnParentHasColEncoding() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); @@ -535,7 +550,7 @@ public Thread newThread(Runnable r) { @Test public void testConcurrentViewCreationParentColDropViewCondition() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); @@ -606,7 +621,7 @@ public Thread newThread(Runnable r) { @Test public void testConcurrentViewCreationWithNewColParentColAddition() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewExtendsPkRestrictionsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewExtendsPkRestrictionsIT.java index 05071ecba75..9e5ac4d6cb2 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewExtendsPkRestrictionsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewExtendsPkRestrictionsIT.java @@ -19,6 +19,7 @@ package org.apache.phoenix.end2end; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.SchemaUtil; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -34,6 +35,7 @@ import static org.apache.phoenix.exception.SQLExceptionCode.CANNOT_CREATE_INDEX_CHILD_VIEWS_EXTEND_PK; import static org.apache.phoenix.exception.SQLExceptionCode.VIEW_CANNOT_EXTEND_PK_WITH_PARENT_INDEXES; import static org.apache.phoenix.query.QueryServices.DISABLE_VIEW_SUBTREE_VALIDATION; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -49,14 +51,14 @@ public class ViewExtendsPkRestrictionsIT extends ParallelStatsDisabledIT { private static final String TENANT_ID = "tenant_01"; private Connection getTenantConnection(final String tenantId) throws Exception { - Properties tenantProps = new Properties(); + Properties tenantProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); return DriverManager.getConnection(getUrl(), tenantProps); } private Connection getTenantConnection(final String tenantId, final boolean disableCreateIndexCheck) throws Exception { - Properties tenantProps = new Properties(); + Properties tenantProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); tenantProps.setProperty(DISABLE_VIEW_SUBTREE_VALIDATION, Boolean.toString(disableCreateIndexCheck)); @@ -69,8 +71,7 @@ public void testViewExtendsPkWithParentTableIndex1() { final String indexName = "idx_" + tableName; final String view01 = "v01_" + tableName; boolean allStmtExecuted = false; - - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + tableName @@ -109,7 +110,7 @@ public void testSchemaViewExtendsPkWithParentTableIndex1() { final String view01 = SchemaUtil.getTableName(schemaName2, "v01_" + tableName); boolean allStmtExecuted = false; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + fullTableName @@ -147,7 +148,7 @@ public void testTenantSchemaViewExtendsPkWithParentTableIndex1() throws Exceptio final String indexName = "idx_" + tableName; final String view01 = SchemaUtil.getTableName(schemaName2, "v01_" + tableName); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + fullTableName + " (TENANT_ID VARCHAR NOT NULL, COL1 CHAR(10) NOT NULL, COL2 CHAR(5) NOT " @@ -184,7 +185,7 @@ public void testViewExtendsPkWithParentTableIndex2() { final String view01 = "v01_" + tableName; boolean allStmtExecuted = false; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + tableName @@ -221,7 +222,7 @@ public void testViewExtendsPkWithViewIndex1() throws Exception { final String index_view01 = "idx_v01_" + tableName; final String index_view02 = "idx_v02_" + tableName; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + tableName @@ -248,7 +249,7 @@ public void testViewExtendsPkWithViewIndex2() { final String index_view01 = "idx_v01_" + tableName; boolean allStmtExecuted = false; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + tableName @@ -291,7 +292,7 @@ public void testSchemaViewExtendsPkWithViewIndex2() { final String index_view01 = "idx_v01_" + tableName; boolean allStmtExecuted = false; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + fullTableName @@ -334,7 +335,7 @@ public void testTenantSchemaViewExtendsPkWithViewIndex2() throws Exception { final String index_view01 = "idx_v01_" + tableName; boolean allStmtExecuted = false; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + fullTableName @@ -384,7 +385,7 @@ public void testViewExtendsPkWithViewIndex3() { final String index_view01 = "idx_v01_" + tableName; boolean allStmtExecuted = false; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + tableName @@ -437,7 +438,7 @@ public void testTenantSchemaViewExtendsPkWithViewIndex3() throws Exception { final String index_view01 = "idx_v01_" + tableName; boolean allStmtExecuted = false; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + fullTableName @@ -497,7 +498,7 @@ public void testTenantSchemaViewExtendsPkWithViewIndex4() throws Exception { final String index_view01 = "idx_v01_" + tableName; boolean allStmtExecuted = false; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))){ final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + fullTableName @@ -559,7 +560,7 @@ public void testTenantSchemaViewExtendsPkWithViewIndex5() throws Exception { final String view05 = SchemaUtil.getTableName(schemaName6, "v05_" + tableName); final String index_view01 = "idx_v01_" + tableName; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + fullTableName @@ -607,7 +608,7 @@ public void testTenantSchemaViewExtendsPkWithViewIndex6() throws Exception { final String index_view01 = "idx_v01_" + tableName; boolean allStmtExecuted = false; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + fullTableName @@ -671,7 +672,7 @@ public void testTenantSchemaViewExtendsPkWithViewIndex7() throws Exception { final String index_table = "idx_" + tableName; boolean allStmtExecuted = false; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + fullTableName @@ -732,7 +733,7 @@ public void testTenantSchemaViewExtendsPkWithViewIndex8() throws Exception { final String view04 = SchemaUtil.getTableName(schemaName5, "v04_" + tableName); final String index_table = "idx_" + tableName; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(DISABLE_VIEW_SUBTREE_VALIDATION, "true"); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { @@ -773,7 +774,7 @@ public void testViewIndexWithChildViewExtendedPk1() throws Exception { final String index_view01 = "idx_v01_" + tableName; final String index_view02 = "idx_v02_" + tableName; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(DISABLE_VIEW_SUBTREE_VALIDATION, "true"); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { @@ -810,7 +811,7 @@ public void testViewIndexWithChildViewExtendedPk4() { final String index_view02 = "idx_v02_" + tableName; boolean allStmtExecuted = false; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + tableName @@ -865,7 +866,7 @@ public void testSchemaViewIndexWithChildViewExtendedPk1() { final String index_view02 = "idx_v02_" + tableName; boolean allStmtExecuted = false; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + fullTableName @@ -920,7 +921,7 @@ public void testTenantSchemaViewIndexWithChildViewExtendedPk1() throws Exception final String index_view02 = "idx_v02_" + tableName; boolean allStmtExecuted = false; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + fullTableName @@ -978,7 +979,7 @@ public void testViewIndexWithChildViewExtendedPk2() { final String index_view02 = "idx_v02_" + tableName; boolean allStmtExecuted = false; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + tableName @@ -1033,7 +1034,7 @@ public void testSchemaViewIndexWithChildViewExtendedPk2() { final String index_view02 = "idx_v02_" + tableName; boolean allStmtExecuted = false; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + fullTableName @@ -1087,7 +1088,7 @@ public void testTenantSchemaViewIndexWithChildViewExtendedPk2() throws Exception final String index_view01 = "idx_v01_" + tableName; boolean allStmtExecuted = false; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + fullTableName @@ -1141,7 +1142,7 @@ public void testViewIndexWithChildViewExtendedPk3() throws Exception { final String index_view01 = "idx_v01_" + tableName; final String index_view02 = "idx_v02_" + tableName; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { final Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE " + tableName diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java index 60de875c401..3140593cbf7 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java @@ -17,12 +17,14 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.thirdparty.com.google.common.collect.Lists .newArrayListWithExpectedSize; import static org.apache.phoenix.coprocessor.PhoenixMetaDataCoprocessorHost .PHOENIX_META_DATA_COPROCESSOR_CONF_KEY; import static org.apache.phoenix.util.TestUtil.analyzeTable; import static org.apache.phoenix.util.TestUtil.getAllSplits; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -57,6 +59,7 @@ import org.apache.phoenix.compile.QueryPlan; import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixPreparedStatement; import org.apache.phoenix.jdbc.PhoenixStatement; import org.apache.phoenix.query.KeyRange; @@ -134,8 +137,14 @@ public static synchronized void doSetup() throws Exception { ViewConcurrencyAndFailureIT.TestMetaDataRegionObserver.class .getName()); serverProps.put("hbase.coprocessor.abortonerror", "false"); - setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), - ReadOnlyProps.EMPTY_PROPS); + serverProps.put(QueryServices.TRANSACTIONS_ENABLED, Boolean.TRUE.toString()); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(serverProps.entrySet().iterator()), + ReadOnlyProps.EMPTY_PROPS); + } else { + setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), + ReadOnlyProps.EMPTY_PROPS); + } // Split SYSTEM.CATALOG once after the mini-cluster is started if (splitSystemCatalog) { // splitSystemCatalog is incompatible with the balancer chore @@ -157,7 +166,7 @@ public void testReadOnlyOnUpdatableView() throws Exception { + " WHERE k3 > 1 and k3 < 50"; testUpdatableView(fullTableName, fullViewName1, fullViewName2, ddl, null, tableDDLOptions); - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { ResultSet rs = stmt.executeQuery("SELECT k1, k2, k3 FROM " + fullViewName2); @@ -187,8 +196,8 @@ public void testReadOnlyOnUpdatableView() throws Exception { @Test public void testReadOnlyViewWithCaseSensitiveTableNames() throws Exception { - try (Connection earlierCon = DriverManager.getConnection(getUrl()); - Connection conn = DriverManager.getConnection(getUrl()); + try (Connection earlierCon = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { String schemaName = TestUtil.DEFAULT_SCHEMA_NAME + "_" + generateUniqueName(); @@ -244,7 +253,7 @@ public void testReadOnlyViewWithCaseSensitiveTableNames() throws Exception { @Test public void testReadOnlyViewWithCaseSensitiveColumnNames() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); @@ -285,7 +294,7 @@ public void testReadOnlyViewWithCaseSensitiveColumnNames() @Test public void testCreateMappedViewWithHbaseNamespace() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.TRUE.toString()); Connection conn1 = DriverManager.getConnection(getUrl(), props); @@ -324,7 +333,7 @@ public void testCreateMappedViewWithHbaseNamespace() throws Exception { @Test public void testViewWithCurrentDate() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); @@ -380,7 +389,7 @@ public void testViewUsesTableLocalIndex() throws Exception { @Test public void testCreateViewSchemaVersion() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); final String schemaName = generateUniqueName(); final String tableName = generateUniqueName(); final String viewName = generateUniqueName(); @@ -394,7 +403,7 @@ public void testCreateViewSchemaVersion() throws Exception { String createViewSql = "CREATE VIEW " + viewFullName + " AS SELECT * FROM " + dataTableFullName + " SCHEMA_VERSION='" + version + "', STREAMING_TOPIC_NAME='" + topicName + "'"; conn.createStatement().execute(createViewSql); - PTable view = conn.unwrap(PhoenixConnection.class).getTableNoCache(viewFullName); + PTable view = conn.unwrap(PhoenixMonitoredConnection.class).getTableNoCache(viewFullName); assertEquals(version, view.getSchemaVersion()); assertEquals(topicName, view.getStreamingTopicName()); } @@ -412,7 +421,7 @@ public void testCreateViewsWithChangeDetectionEnabled() throws Exception { String fullTenantViewName = SchemaUtil.getTableName(schemaName, tenantViewName); PTable globalView = null; - try (PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl())) { + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES));) { String ddl = "CREATE TABLE " + fullTableName + " (id char(1) NOT NULL," + " col1 integer NOT NULL," + " col2 bigint NOT NULL," + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1, col2)) " + @@ -436,9 +445,9 @@ public void testCreateViewsWithChangeDetectionEnabled() throws Exception { globalViewWithParents = builder.setColumns(globalViewWithParents.getColumns()).build(); AlterTableIT.verifySchemaExport(globalViewWithParents, getUtility().getConfiguration()); } - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); - try (PhoenixConnection tenantConn = (PhoenixConnection) DriverManager.getConnection(getUrl(), props)) { + try (PhoenixMonitoredConnection tenantConn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), props)) { String tenantViewDdl = "CREATE VIEW " + fullTenantViewName + " (id3 VARCHAR PRIMARY KEY, col4 VARCHAR NULL) " + " AS SELECT * FROM " + fullGlobalViewName + " CHANGE_DETECTION_ENABLED=true"; @@ -462,7 +471,7 @@ public void testCreateTenantViewTimestamp() throws Exception { } private void createViewTimestampHelper(String tenantId) throws SQLException { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); if (tenantId != null) { props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); } @@ -479,7 +488,7 @@ private void createViewTimestampHelper(String tenantId) throws SQLException { String viewDDL = "CREATE VIEW " + viewFullName + " AS SELECT * " + "FROM " + dataTableFullName; long startTS = EnvironmentEdgeManager.currentTimeMillis(); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute(tableDDL); } try (Connection conn = DriverManager.getConnection(getUrl(), props)) { @@ -500,7 +509,7 @@ public void testCreateChangeDetectionEnabledTable() throws Exception { String fullTableName = SchemaUtil.getTableName(schemaName, tableName); String viewName = generateUniqueName(); String fullViewName = SchemaUtil.getTableName(schemaName, viewName); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String ddl = "CREATE TABLE " + fullTableName + " (id char(1) NOT NULL," + " col1 integer NOT NULL," + " col2 bigint NOT NULL," + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1, col2)) " + @@ -510,7 +519,7 @@ public void testCreateChangeDetectionEnabledTable() throws Exception { String viewDdl = "CREATE VIEW " + fullViewName + " AS SELECT * FROM " + fullTableName + " CHANGE_DETECTION_ENABLED=true"; conn.createStatement().execute(viewDdl); - PTable view = conn.unwrap(PhoenixConnection.class).getTableNoCache(fullViewName); + PTable view = conn.unwrap(PhoenixMonitoredConnection.class).getTableNoCache(fullViewName); assertTrue(view.isChangeDetectionEnabled()); assertEquals(DefaultSchemaRegistryRepository.getSchemaId(view), view.getExternalSchemaId()); @@ -529,7 +538,7 @@ private void testViewUsesTableIndex(boolean localIndex) throws Exception { String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()) + (localIndex ? "_WITH_LI" : "_WITHOUT_LI"); - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()){ String ddl = "CREATE TABLE " + fullTableName + " (k1 INTEGER NOT NULL, " @@ -627,7 +636,7 @@ public void testCreateChildViewWithBaseTableIndex(boolean localIndex) String indexName = "I_" + generateUniqueName(); String fullChildViewName = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { String sql = "CREATE TABLE " + fullTableName + " (ID INTEGER NOT NULL PRIMARY KEY, HOST VARCHAR(10)," @@ -661,9 +670,9 @@ public void testCreateChildViewWithBaseTableIndex(boolean localIndex) } catch (Exception ignore) { } // Check view inherits index, but child view doesn't - PTable table = conn.unwrap(PhoenixConnection.class).getTable(fullViewName); + PTable table = conn.unwrap(PhoenixMonitoredConnection.class).getTable(fullViewName); assertEquals(1, table.getIndexes().size()); - table = conn.unwrap(PhoenixConnection.class).getTable(fullChildViewName); + table = conn.unwrap(PhoenixMonitoredConnection.class).getTable(fullChildViewName); assertEquals(0, table.getIndexes().size()); ResultSet rs = stmt.executeQuery("select count(*) from " @@ -679,7 +688,7 @@ public void testCreateChildViewWithBaseTableIndex(boolean localIndex) @Test public void testCreateViewDefinesPKColumn() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); @@ -721,7 +730,7 @@ public void testCreateViewDefinesPKColumn() throws Exception { @Test public void testQueryViewStatementOptimization() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES));) { String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String fullViewName1 = SchemaUtil.getTableName(SCHEMA2, @@ -769,7 +778,7 @@ private void assertPKs(ResultSet rs, String[] expectedPKs) @Test public void testCompositeDescPK() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); try (Connection globalConn = DriverManager.getConnection(getUrl(), props)) { String tableName = SchemaUtil.getTableName(SCHEMA1, @@ -800,7 +809,7 @@ public void testCompositeDescPK() throws Exception { } String tenantId = "tenantId"; - Properties tenantProps = new Properties(); + Properties tenantProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); // create a tenant specific view try (Connection tenantConn = DriverManager.getConnection(getUrl(), @@ -950,7 +959,7 @@ public void testCompositeDescPK() throws Exception { public void testCreateViewWithUndefinedSameColumnName() throws Exception { String fullViewName = generateUniqueName(); - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { String ddl = "CREATE VIEW " + fullViewName + " AS SELECT * FROM " + fullViewName + @@ -968,7 +977,7 @@ public void testCreateViewWithUndefinedSameColumnName() throws Exception { @Test //creating view with same name on top of a non existent table public void testCreateViewOnTopOfUndefinedTableWithSameName() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { String fullViewName = generateUniqueName(); @@ -986,7 +995,7 @@ public void testCreateViewOnTopOfUndefinedTableWithSameName() throws Exception { @Test //creating view with same name as the parent table public void testCreateViewOnTopOfTableWithSameName() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { String fullTableName = generateUniqueName(); @@ -1055,7 +1064,7 @@ private void upsertRows(String viewName, Connection tenantConn) public static void testUpdatableView(String fullTableName, String fullViewName, String fullChildViewName, String childViewDDL, Integer saltBuckets, String tableDDLOptions) throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { if (saltBuckets != null) { if (tableDDLOptions.length() != 0) tableDDLOptions += ","; @@ -1129,7 +1138,7 @@ public static Pair testUpdatableViewIndex( String fullTableName, Integer saltBuckets, boolean localIndex, String viewName) throws Exception { ResultSet rs; - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { String viewIndexName1 = "I_" + generateUniqueName(); String schemaName = SchemaUtil.getSchemaNameFromFullName(viewName); @@ -1282,7 +1291,7 @@ public static Pair testUpdatableViewIndex( @Test public void testDisallowCreatingViewsOnSystemTable() throws SQLException { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String viewDDL = "CREATE VIEW " + generateUniqueName() + " AS SELECT * FROM SYSTEM.CATALOG"; try (Statement stmt = conn.createStatement()){ diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIndexIdRetrieveIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIndexIdRetrieveIT.java index 82f64f7266c..496bd0403f5 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIndexIdRetrieveIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIndexIdRetrieveIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_NAME; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_SCHEM; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.VIEW_INDEX_ID; @@ -67,7 +68,11 @@ public class ViewIndexIdRetrieveIT extends BaseTest { @BeforeClass public static synchronized void setUp() throws Exception { Map props = new HashMap<>(); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()), new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @Test @@ -91,7 +96,7 @@ private void testSelectViewIndexId(boolean isTestingLongViewIndexId) throws Exce String viewName = generateUniqueName(); String viewFullName = SchemaUtil.getTableName(schema, viewName); String viewIndexName = generateUniqueName(); - try (final Connection conn = DriverManager.getConnection(url,props); + try (final Connection conn = DriverManager.getConnection(getUrl(),props); final Statement stmt = conn.createStatement()) { stmt.execute(String.format(BASE_TABLE_DDL, fullTableName)); stmt.execute(String.format(VIEW_DDL, viewFullName, fullTableName)); @@ -119,7 +124,7 @@ public void testMixedCase() throws Exception { String viewIndexName1 = generateUniqueName(); // view index id data type is long - try (final Connection conn = DriverManager.getConnection(url,propsForLongType); + try (final Connection conn = DriverManager.getConnection(getUrl(),propsForLongType); final Statement stmt = conn.createStatement()) { stmt.execute(String.format(BASE_TABLE_DDL, fullTableName)); stmt.execute(String.format(VIEW_DDL, viewFullName, fullTableName)); @@ -136,7 +141,7 @@ public void testMixedCase() throws Exception { String viewIndexName2 = generateUniqueName(); Properties propsForShortType = PropertiesUtil.deepCopy(TEST_PROPERTIES); propsForShortType.setProperty(LONG_VIEW_INDEX_ENABLED_ATTRIB, "false"); - try (final Connection conn = DriverManager.getConnection(url,propsForShortType); + try (final Connection conn = DriverManager.getConnection(getUrl(),propsForShortType); final Statement stmt = conn.createStatement()) { stmt.execute(String.format(VIEW_INDEX_DDL, viewIndexName2, viewFullName)); @@ -148,7 +153,7 @@ public void testMixedCase() throws Exception { } // check select * from syscat - try (final Connection conn = DriverManager.getConnection(url); + try (final Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES)); final Statement stmt = conn.createStatement()) { ResultSet rs = stmt.executeQuery(String.format(SELECT_ALL)); boolean checkShort = false; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewMetadataIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewMetadataIT.java index 4cbfc8bf403..e710dde62d6 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewMetadataIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewMetadataIT.java @@ -17,6 +17,7 @@ */ package org.apache.phoenix.end2end; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.thirdparty.com.google.common.collect.Lists .newArrayListWithExpectedSize; import static org.apache.phoenix.coprocessor.PhoenixMetaDataCoprocessorHost @@ -43,6 +44,7 @@ import static org.apache.phoenix.schema.PTable.TaskType.DROP_CHILD_VIEWS; import static org.apache.phoenix.util.ByteUtil.EMPTY_BYTE_ARRAY; import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; @@ -77,6 +79,7 @@ import org.apache.phoenix.coprocessor.TaskRegionObserver; import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.ConnectionQueryServices; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.ColumnAlreadyExistsException; @@ -89,6 +92,7 @@ import org.apache.phoenix.schema.TableNotFoundException; import org.apache.phoenix.util.PhoenixRuntime; import org.apache.phoenix.util.QueryUtil; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.util.ViewUtil; @@ -144,8 +148,12 @@ public static synchronized void doSetup() throws Exception { // server and pass in server-side properties when running the drop // child views tasks serverProps.put(DROP_METADATA_ATTRIB, Boolean.TRUE.toString()); - setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), - new ReadOnlyProps(clientProps.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(serverProps.entrySet().iterator()), + new ReadOnlyProps(clientProps.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), + new ReadOnlyProps(clientProps.entrySet().iterator())); } // Split SYSTEM.CATALOG once after the mini-cluster is started if (splitSystemCatalog) { // splitSystemCatalog is incompatible with the balancer chore @@ -162,7 +170,7 @@ public static synchronized void doSetup() throws Exception { @Test public void testCreateViewWithUpdateCacheFrquency() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn1 = DriverManager.getConnection(getUrl(), props); conn1.setAutoCommit(true); String tableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); @@ -194,7 +202,7 @@ public void testCreateViewFromHBaseTable() throws Exception { HBaseTestingUtility testUtil = getUtility(); Admin admin = testUtil.getAdmin(); admin.createTable(builder.build()); - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); //PK is not specified, without where clause try { @@ -244,12 +252,12 @@ public void testCreateViewMappedToExistingHbaseTableWithNSMappingEnabled() final String TBL = "TBL_" + generateUniqueName(); final String CF = "CF"; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.TRUE.toString()); try (Connection conn = DriverManager.getConnection(getUrl(), props); - Admin admin = conn.unwrap(PhoenixConnection.class) + Admin admin = conn.unwrap(PhoenixMonitoredConnection.class) .getQueryServices().getAdmin()) { conn.createStatement().execute("CREATE SCHEMA " + NS); @@ -330,7 +338,7 @@ public void testCreateViewMappedToExistingHbaseTableWithNSMappingEnabled() @Test public void testRecreateDroppedTableWithChildViews() throws Exception { - PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl()); + PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String fullViewName1 = SchemaUtil.getTableName(SCHEMA2, @@ -385,8 +393,7 @@ public void testAlterTableIsResilientToOrphanLinks() throws SQLException { final String alterTableDDL = "ALTER TABLE %s ADD NEW_COL1 VARCHAR"; createOrphanLink(SCHEMA1, parent1TableName, parent2TableName, SCHEMA2, viewName); - - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { // Should not fail since this table is unrelated to the view // in spite of the orphan parent->child link @@ -412,8 +419,7 @@ public void testDropTableIsResilientToOrphanLinks() throws SQLException { final String dropTableNoCascadeDDL = "DROP TABLE %s "; createOrphanLink(SCHEMA1, parent1TableName, parent2TableName, SCHEMA2, viewName); - - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement stmt = conn.createStatement()) { // Should not fail since this table is unrelated to the view // in spite of the orphan parent->child link @@ -478,7 +484,7 @@ public void testViewHierarchyWithOrphanLinks() throws Exception { CHILD_VIEW_LEVEL_1_SCHEMA, level1ViewName1); // Create other legit views on top of parent1 and parent2 - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES));) { conn.createStatement().execute(String.format( CREATE_CHILD_VIEW_LEVEL_1_DDL, CHILD_VIEW_LEVEL_1_SCHEMA, level1ViewName3, @@ -501,7 +507,7 @@ public void testViewHierarchyWithOrphanLinks() throws Exception { CHILD_VIEW_LEVEL_1_SCHEMA, level1ViewName6, BASE_TABLE_SCHEMA, parent2TableName)); } - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.put(TENANT_ID_ATTRIB, tenantId); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { conn.createStatement().execute(String.format( @@ -581,9 +587,8 @@ public void testViewHierarchyWithOrphanLinks() throws Exception { t001.level2view2->t001.level3view1 */ - - try (Connection conn = DriverManager.getConnection(getUrl())) { - ConnectionQueryServices cqs = conn.unwrap(PhoenixConnection.class) + try (Connection conn = DriverManager.getConnection(getUrl(),PropertiesUtil.deepCopy(TEST_PROPERTIES))) { + ConnectionQueryServices cqs = conn.unwrap(PhoenixMonitoredConnection.class) .getQueryServices(); try (Table childLinkTable = cqs.getTable(SchemaUtil.getPhysicalName( SYSTEM_LINK_HBASE_TABLE_NAME.toBytes(), @@ -697,8 +702,8 @@ static void createOrphanLink(String parentSchema, String parent1, + "TABLE_NAME='%s' AND COLUMN_FAMILY='%s' AND " + LINK_TYPE + " = " + PTable.LinkType.CHILD_TABLE.getSerializedValue(); - try (Connection conn = DriverManager.getConnection(getUrl()); - Statement stmt = conn.createStatement()) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Statement stmt = conn.createStatement()) { stmt.execute(String.format(CREATE_BASE_TABLE_DDL, parentSchema, parent1)); stmt.execute(String.format(CREATE_BASE_TABLE_DDL, parentSchema, @@ -732,7 +737,7 @@ void runDropChildViewsTask() { @Test public void testRecreateIndexWhoseAncestorWasDropped() throws Exception { - PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl()); + PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String fullTableName1 = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String fullViewName1 = SchemaUtil.getTableName(SCHEMA2, @@ -780,7 +785,7 @@ public void testRecreateIndexWhoseAncestorWasDropped() throws Exception { @Test public void testRecreateViewWhoseParentWasDropped() throws Exception { - PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl()); + PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String fullTableName1 = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String fullViewName1 = SchemaUtil.getTableName(SCHEMA2, @@ -822,8 +827,7 @@ public void testRepeatedCreateAndDropCascadeTableWorks() throws Exception { String fullTableName = SchemaUtil.getTableName(SCHEMA1, tableName); String fullViewName = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); - - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { createTableViewAndDropCascade(conn, fullTableName, fullViewName, false); validateViewDoesNotExist(conn, fullViewName); @@ -850,7 +854,7 @@ public void testDropTableCascadeWithChildViewWithIndex() String fullTableName = SchemaUtil.getTableName(SCHEMA1, tableName); String fullViewName = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { createTableViewAndDropCascade(conn, fullTableName, fullViewName, true); validateViewDoesNotExist(conn, fullViewName); @@ -922,7 +926,7 @@ public void testViewAndTableInDifferentSchemas() throws Exception { private void testViewAndTableInDifferentSchemas(boolean isNamespaceMapped) throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.toString(isNamespaceMapped)); Connection conn = DriverManager.getConnection(getUrl(),props); @@ -945,12 +949,12 @@ private void testViewAndTableInDifferentSchemas(boolean isNamespaceMapped) } String ddl = "CREATE TABLE " + fullTableName1 + " (k INTEGER NOT NULL PRIMARY KEY, v1 DATE)"; - Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices() + Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices() .getAdmin(); conn.createStatement().execute(ddl); assertTrue(admin.tableExists(SchemaUtil.getPhysicalTableName( SchemaUtil.normalizeIdentifier(fullTableName1), - conn.unwrap(PhoenixConnection.class).getQueryServices() + conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices() .getProps()))); ddl = "CREATE VIEW " + fullViewName1 @@ -989,7 +993,7 @@ private void testViewAndTableInDifferentSchemas(boolean isNamespaceMapped) @Test public void testViewAndTableAndDropCascade() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String fullViewName1 = SchemaUtil.getTableName(SCHEMA2, @@ -1038,7 +1042,7 @@ public void testUpdatingPropertyOnBaseTable() throws Exception { generateUniqueName()); String fullViewName = SchemaUtil.getTableName(SCHEMA2, generateUniqueName()); - try (PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl())) { + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement() .execute("create table " + fullTableName + "(tenantId CHAR(15) NOT NULL, pk1 integer " @@ -1064,7 +1068,7 @@ public void testUpdatingPropertyOnBaseTable() throws Exception { @Test public void testViewAddsPKColumnWhoseParentsLastPKIsVarLength() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String fullViewName = SchemaUtil.getTableName(SCHEMA2, @@ -1102,7 +1106,7 @@ public void testViewAddsPKColumnWhoseParentsLastPKIsVarLength() @Test(expected=ColumnAlreadyExistsException.class) public void testViewAddsClashingPKColumn() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String fullViewName = SchemaUtil.getTableName(SCHEMA2, @@ -1124,8 +1128,8 @@ public void testViewAddsClashingPKColumn() throws Exception { @Test public void testQueryWithSeparateConnectionForViewOnTableThatHasIndex() throws SQLException { - try (Connection conn = DriverManager.getConnection(getUrl()); - Connection conn2 = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); + Connection conn2 = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement s = conn.createStatement(); Statement s2 = conn2.createStatement()) { String tableName = SchemaUtil.getTableName(SCHEMA1, @@ -1140,7 +1144,7 @@ public void testQueryWithSeparateConnectionForViewOnTableThatHasIndex() @Test public void testQueryForViewOnTableThatHasIndex() throws SQLException { - try (Connection conn = DriverManager.getConnection(getUrl()); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); Statement s = conn.createStatement()) { String tableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); @@ -1180,7 +1184,7 @@ private void helpTestQueryForViewOnTableThatHasIndex(Statement s1, @Test public void testViewAndTableAndDropCascadeWithIndexes() throws Exception { // Setup - Tables and Views with Indexes - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String ddl = "CREATE TABLE " + fullTableName @@ -1221,7 +1225,7 @@ public void testViewAndTableAndDropCascadeWithIndexes() throws Exception { @Test public void testViewAddsNotNullPKColumn() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String fullViewName = SchemaUtil.getTableName(SCHEMA2, @@ -1247,7 +1251,7 @@ public void testViewAddsNotNullPKColumn() throws Exception { @Test public void testDisallowDropOfColumnOnParentTable() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String viewName = SchemaUtil.getTableName(SCHEMA2, @@ -1271,7 +1275,7 @@ public void testDisallowDropOfColumnOnParentTable() throws Exception { @Test public void testDisallowDropOfReferencedColumn() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String fullViewName1 = SchemaUtil.getTableName(SCHEMA2, @@ -1321,7 +1325,7 @@ public void testDisallowDropOfReferencedColumn() throws Exception { @Test public void testViewAddsPKColumn() throws Exception { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String viewName = generateUniqueName(); @@ -1347,7 +1351,7 @@ public void testViewAddsPKColumn() throws Exception { @Test public void testCreateViewDefinesPKConstraint() throws Exception { - PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl()); + PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); String fullTableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); String fullViewName = SchemaUtil.getTableName(SCHEMA2, @@ -1392,7 +1396,7 @@ public void testAncestorLastDDLMapPopulatedInViewAndIndexHierarchy() throws SQLE / index2(tenant1) */ - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { String baseTableDDL = "CREATE TABLE " + baseTable + " (TENANT_ID VARCHAR NOT NULL, PK1 VARCHAR NOT NULL, V1 VARCHAR, V2 VARCHAR CONSTRAINT NAME_PK PRIMARY KEY(TENANT_ID, PK1)) MULTI_TENANT = true "; conn.createStatement().execute(baseTableDDL); String index1DDL = "CREATE INDEX " + index1 + " ON " + baseTable + "(V1)"; @@ -1490,7 +1494,7 @@ public void testAncestorLastDDLMapPopulatedInViewAndIndexHierarchy() throws SQLE } private Connection getTenantConnection(String tenantId) throws SQLException { - Properties tenantProps = new Properties(); + Properties tenantProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); return DriverManager.getConnection(getUrl(), tenantProps); } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewTTLIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewTTLIT.java index 96eeb971592..d13062d4c6a 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewTTLIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewTTLIT.java @@ -19,6 +19,7 @@ package org.apache.phoenix.end2end; import static java.util.Arrays.asList; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.query.PhoenixTestBuilder.DDLDefaults.COLUMN_TYPES; import static org.apache.phoenix.query.PhoenixTestBuilder.DDLDefaults.DEFAULT_SCHEMA_NAME; import static org.apache.phoenix.query.PhoenixTestBuilder.DDLDefaults.MAX_ROWS; @@ -28,6 +29,7 @@ import static org.apache.phoenix.query.PhoenixTestBuilder.DDLDefaults.TENANT_VIEW_PK_COLUMNS; import static org.apache.phoenix.query.PhoenixTestBuilder.DDLDefaults.TENANT_VIEW_PK_TYPES; import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -47,6 +49,7 @@ import org.apache.phoenix.coprocessorclient.BaseScannerRegionObserverConstants; import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixResultSet; import org.apache.phoenix.jdbc.PhoenixStatement; import org.apache.phoenix.query.PhoenixTestBuilder; @@ -75,18 +78,13 @@ import org.apache.phoenix.thirdparty.com.google.common.base.Joiner; import org.apache.phoenix.thirdparty.com.google.common.base.Preconditions; import org.apache.phoenix.thirdparty.com.google.common.collect.Lists; -import org.apache.phoenix.util.EnvironmentEdgeManager; -import org.apache.phoenix.util.ManualEnvironmentEdge; -import org.apache.phoenix.util.ReadOnlyProps; -import org.apache.phoenix.util.ScanUtil; -import org.apache.phoenix.util.SchemaUtil; +import org.apache.phoenix.util.*; 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; - @Category(NeedsOwnMiniClusterTest.class) public class ViewTTLIT extends BaseViewTTLIT { @@ -106,9 +104,14 @@ public static void doSetup() throws Exception { put(BaseScannerRegionObserverConstants.PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY, Integer.toString(0)); put(QueryServices.PHOENIX_VIEW_TTL_TENANT_VIEWS_PER_SCAN_LIMIT, String.valueOf(1)); }}; - - setUpTestDriver(new ReadOnlyProps(ReadOnlyProps.EMPTY_PROPS, - DEFAULT_PROPERTIES.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(ReadOnlyProps.EMPTY_PROPS, + DEFAULT_PROPERTIES.entrySet().iterator()),new ReadOnlyProps(ReadOnlyProps.EMPTY_PROPS, + DEFAULT_PROPERTIES.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(ReadOnlyProps.EMPTY_PROPS, + DEFAULT_PROPERTIES.entrySet().iterator())); + } } @Before @@ -303,7 +306,7 @@ public void testPhoenixTTLWithAlterView() throws Exception { PTableType.INDEX.getSerializedValue(), "0"); String tenantURL = getUrl() + ';' + TENANT_ID_ATTRIB + '=' + tenantId; - try (Connection connection = DriverManager.getConnection(tenantURL)) { + try (Connection connection = DriverManager.getConnection(tenantURL,PropertiesUtil.deepCopy(TEST_PROPERTIES))) { try (Statement stmt = connection.createStatement()) { // View TTL is set to 120s => 120000 ms String sql = String @@ -371,7 +374,7 @@ public void testTTLAlreadyDefinedInHierarchyWhenAlterTenantView() throws Excepti PTableType.VIEW.getSerializedValue(), "0"); String tenantURL = getUrl() + ';' + TENANT_ID_ATTRIB + '=' + tenantId; - try (Connection connection = DriverManager.getConnection(tenantURL)) { + try (Connection connection = DriverManager.getConnection(tenantURL, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { try (Statement stmt = connection.createStatement()) { // View TTL is set to 120s => 120000 ms String sql = String @@ -414,7 +417,7 @@ public void testTTLAlreadyDefinedInHierarchyWhenAlterGlobalView() throws Excepti assertSyscatHavePhoenixTTLRelatedColumns(tenantId, schemaName, indexOnTenantViewName, PTableType.INDEX.getSerializedValue(), "0"); - try (Connection connection = DriverManager.getConnection(getUrl())) { + try (Connection connection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { try (Statement stmt = connection.createStatement()) { // View TTL is set to 120s => 120000 ms String sql = String @@ -458,7 +461,7 @@ public void testAlterViewWithNoTTLPropertySucceed() throws Exception { PTableType.INDEX.getSerializedValue(), "0"); // ALTER global view - try (Connection connection = DriverManager.getConnection(getUrl())) { + try (Connection connection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { try (Statement stmt = connection.createStatement()) { String sql = String .format(ALTER_SQL_WITH_NO_TTL, schemaName, globalViewName, "COL_30"); @@ -468,7 +471,7 @@ public void testAlterViewWithNoTTLPropertySucceed() throws Exception { // ALTER tenant view String tenantURL = getUrl() + ';' + TENANT_ID_ATTRIB + '=' + tenantId; - try (Connection connection = DriverManager.getConnection(tenantURL)) { + try (Connection connection = DriverManager.getConnection(tenantURL, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { try (Statement stmt = connection.createStatement()) { String sql = String .format(ALTER_SQL_WITH_NO_TTL, schemaName, tenantViewName, "COL_100"); @@ -495,7 +498,7 @@ public void testResetViewTTL() throws Exception { String indexOnTenantViewName = String .format("IDX_%s", stripQuotes(schemaBuilder.getEntityKeyPrefix())); - try (Connection connection = DriverManager.getConnection(getUrl())) { + try (Connection connection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { try (Statement stmt = connection.createStatement()) { // View TTL is set to 'NONE' String sql = String @@ -624,7 +627,7 @@ public void testWithTenantViewAndNoGlobalView() throws Exception { String tenantConnectUrl = getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(); - try (Connection writeConnection = DriverManager.getConnection(tenantConnectUrl)) { + try (Connection writeConnection = DriverManager.getConnection(tenantConnectUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { writeConnection.setAutoCommit(true); dataWriter.setConnection(writeConnection); dataWriter.setDataSupplier(dataSupplier); @@ -731,7 +734,7 @@ public void testWithSQLUsingIndexWithCoveredColsUpdates() throws Exception { List rowKeyColumns = Lists.newArrayList("COL6"); String tenantConnectUrl = getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(); - try (Connection writeConnection = DriverManager.getConnection(tenantConnectUrl)) { + try (Connection writeConnection = DriverManager.getConnection(tenantConnectUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { writeConnection.setAutoCommit(true); dataWriter.setConnection(writeConnection); dataWriter.setDataSupplier(dataSupplier); @@ -833,7 +836,7 @@ public void testWithSQLUsingIndexAndNoCoveredColsUpdates() throws Exception { List rowKeyColumns = Lists.newArrayList("COL6"); String tenantConnectUrl = getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(); - try (Connection writeConnection = DriverManager.getConnection(tenantConnectUrl)) { + try (Connection writeConnection = DriverManager.getConnection(tenantConnectUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { writeConnection.setAutoCommit(true); dataWriter.setConnection(writeConnection); dataWriter.setDataSupplier(dataSupplier); @@ -943,7 +946,7 @@ public void testWithSQLUsingIndexAndMultiLevelViews() throws Exception { schemaBuilder.getEntityTenantViewName()); String tConnectUrl = getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(); - try (Connection tConnection = DriverManager.getConnection(tConnectUrl)) { + try (Connection tConnection = DriverManager.getConnection(tConnectUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { tConnection.createStatement().execute(level3ViewCreateSQL); } @@ -982,7 +985,7 @@ public void testWithSQLUsingIndexAndMultiLevelViews() throws Exception { List rowKeyColumns = Lists.newArrayList("COL6"); String tenantConnectUrl = getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(); - try (Connection writeConnection = DriverManager.getConnection(tenantConnectUrl)) { + try (Connection writeConnection = DriverManager.getConnection(tenantConnectUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { writeConnection.setAutoCommit(true); dataWriter.setConnection(writeConnection); dataWriter.setDataSupplier(dataSupplier); @@ -1100,7 +1103,7 @@ public void testWithVariousSQLs() throws Exception { List rowKeyColumns = Lists.newArrayList("ID", "ZID"); String tenantConnectUrl = getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(); - try (Connection writeConnection = DriverManager.getConnection(tenantConnectUrl)) { + try (Connection writeConnection = DriverManager.getConnection(tenantConnectUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { writeConnection.setAutoCommit(true); dataWriter.setConnection(writeConnection); dataWriter.setDataSupplier(dataSupplier); @@ -1201,7 +1204,7 @@ public void testWithVariousSQLsForMultipleTenants() throws Exception { List rowKeyColumns = Lists.newArrayList("ID", "ZID"); String tenantConnectUrl = getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(); - try (Connection writeConnection = DriverManager.getConnection(tenantConnectUrl)) { + try (Connection writeConnection = DriverManager.getConnection(tenantConnectUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { writeConnection.setAutoCommit(true); dataWriter.setConnection(writeConnection); dataWriter.setDataSupplier(dataSupplier); @@ -1291,7 +1294,7 @@ public void testWithVariousSQLsForMultipleViews() throws Exception { List rowKeyColumns = Lists.newArrayList("ZID"); String tenantConnectUrl = getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(); - try (Connection writeConnection = DriverManager.getConnection(tenantConnectUrl)) { + try (Connection writeConnection = DriverManager.getConnection(tenantConnectUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { writeConnection.setAutoCommit(true); dataWriter.setConnection(writeConnection); dataWriter.setDataSupplier(dataSupplier); @@ -1416,7 +1419,7 @@ public void testGlobalAndTenantViewTTLInheritance1() throws Exception { List rowKeyColumns = Lists.newArrayList("ID", "ZID"); String tenant1ConnectUrl = getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(); - try (Connection writeConnection = DriverManager.getConnection(tenant1ConnectUrl)) { + try (Connection writeConnection = DriverManager.getConnection(tenant1ConnectUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { writeConnection.setAutoCommit(true); dataWriter.setConnection(writeConnection); dataWriter.setDataSupplier(dataSupplier); @@ -1532,7 +1535,7 @@ public void testGlobalAndTenantViewTTLInheritance2() throws Exception { List rowKeyColumns = Lists.newArrayList("ID", "ZID"); String tenant1ConnectUrl = getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions().getTenantId(); - try (Connection writeConnection = DriverManager.getConnection(tenant1ConnectUrl)) { + try (Connection writeConnection = DriverManager.getConnection(tenant1ConnectUrl, PropertiesUtil.deepCopy(TEST_PROPERTIES))) { writeConnection.setAutoCommit(true); dataWriter.setConnection(writeConnection); dataWriter.setDataSupplier(dataSupplier); @@ -1581,7 +1584,7 @@ public void testScanAttributes() throws Exception { String viewName = schemaBuilder.getEntityTenantViewName(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); String tenantConnectUrl = getUrl() + ';' + TENANT_ID_ATTRIB + '=' + schemaBuilder.getDataOptions() diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewTTLNotEnabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewTTLNotEnabledIT.java index d768752b75b..c890f75c522 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewTTLNotEnabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewTTLNotEnabledIT.java @@ -26,12 +26,14 @@ import org.apache.phoenix.coprocessorclient.BaseScannerRegionObserverConstants; import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixResultSet; import org.apache.phoenix.jdbc.PhoenixStatement; import org.apache.phoenix.query.PhoenixTestBuilder; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.thirdparty.com.google.common.base.Preconditions; import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.ScanUtil; import org.junit.Assert; @@ -47,9 +49,10 @@ import java.util.Map; import java.util.Properties; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.fail; - @Category(NeedsOwnMiniClusterTest.class) public class ViewTTLNotEnabledIT extends ParallelStatsDisabledIT { @@ -59,7 +62,11 @@ public static synchronized void doSetup() throws Exception { props.put(BaseScannerRegionObserverConstants.PHOENIX_MAX_LOOKBACK_AGE_CONF_KEY, Integer.toString(60*60)); // An hour props.put(QueryServices.USE_STATS_FOR_PARALLELIZATION, Boolean.toString(false)); props.put(QueryServices.PHOENIX_VIEW_TTL_ENABLED, Boolean.toString(false)); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @Test public void testCreateViewWithTTLWithConfigFalse() throws Exception { @@ -85,7 +92,7 @@ public void testAlterViewWithTTLWithConfigFalse() throws Exception { globalViewOptions).build(); String dml = "ALTER VIEW " + schemaBuilder.getEntityGlobalViewName() + " SET TTL = 10000"; - try (Connection connection = DriverManager.getConnection(getUrl())){ + try (Connection connection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))){ try { connection.createStatement().execute(dml); fail(); @@ -106,13 +113,13 @@ public void testSettingTTLFromTableToViewWithConfigDisabled() throws Exception { schemaBuilder.withTableOptions(tableOptions).withGlobalViewOptions( globalViewOptions).build(); - try (Connection connection = DriverManager.getConnection(getUrl())){ + try (Connection connection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))){ String dml = "ALTER TABLE " + schemaBuilder.getEntityTableName() + " SET TTL = NONE"; connection.createStatement().execute(dml); //Clearing cache as metaDataCaching is not there for TTL usecase - connection.unwrap(PhoenixConnection.class).getQueryServices().clearCache(); + connection.unwrap(PhoenixMonitoredConnection.class).getQueryServices().clearCache(); try { dml = "ALTER VIEW " + schemaBuilder.getEntityGlobalViewName() + " SET TTL = 10000"; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewTTLWithLongViewIndexEnabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewTTLWithLongViewIndexEnabledIT.java index 935d472303f..904ad86a322 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewTTLWithLongViewIndexEnabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewTTLWithLongViewIndexEnabledIT.java @@ -31,6 +31,8 @@ import org.junit.Test; import org.junit.experimental.categories.Category; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; + @Category(NeedsOwnMiniClusterTest.class) public class ViewTTLWithLongViewIndexEnabledIT extends BaseViewTTLIT { @@ -51,8 +53,14 @@ public static final void doSetup() throws Exception { put(QueryServices.PHOENIX_VIEW_TTL_TENANT_VIEWS_PER_SCAN_LIMIT, String.valueOf(1)); }}; - setUpTestDriver(new ReadOnlyProps(ReadOnlyProps.EMPTY_PROPS, - DEFAULT_PROPERTIES.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(ReadOnlyProps.EMPTY_PROPS, + DEFAULT_PROPERTIES.entrySet().iterator()), new ReadOnlyProps(ReadOnlyProps.EMPTY_PROPS, + DEFAULT_PROPERTIES.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(ReadOnlyProps.EMPTY_PROPS, + DEFAULT_PROPERTIES.entrySet().iterator())); + } } @Test diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewUtilIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewUtilIT.java index 60150ed2021..acd6d4e0585 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewUtilIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewUtilIT.java @@ -24,6 +24,7 @@ import org.apache.hadoop.hbase.util.Pair; import org.apache.phoenix.coprocessorclient.TableInfo; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.ConnectionQueryServices; import org.apache.phoenix.schema.PTable; import org.apache.phoenix.util.*; @@ -52,24 +53,23 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; - @Category(ParallelStatsDisabledTest.class) public class ViewUtilIT extends ParallelStatsDisabledIT { @Test public void testGetSystemTableForChildLinks() throws Exception { assertEquals(SYSTEM_LINK_HBASE_TABLE_NAME, ViewUtil.getSystemTableForChildLinks( - MIN_SPLITTABLE_SYSTEM_CATALOG, config)); + MIN_SPLITTABLE_SYSTEM_CATALOG, getConfiguration())); // lower version should also give CHILD_LINK table as server upgrade to advanced version assertEquals(SYSTEM_LINK_HBASE_TABLE_NAME, ViewUtil.getSystemTableForChildLinks( - MIN_SPLITTABLE_SYSTEM_CATALOG - 1, config)); + MIN_SPLITTABLE_SYSTEM_CATALOG - 1, getConfiguration())); } @Test public void testHasChildViewsInGlobalViewCase() throws Exception { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - TableName catalogOrChildTableName = ViewUtil.getSystemTableForChildLinks(0, config); + TableName catalogOrChildTableName = ViewUtil.getSystemTableForChildLinks(0, getConfiguration()); String schema = generateUniqueName(); byte[] schemaInBytes = schema.getBytes(StandardCharsets.UTF_8); byte[] tenantIdInBytes = new byte[0]; @@ -94,9 +94,9 @@ public void testHasChildViewsInGlobalViewCase() throws Exception { conn.createStatement().execute( String.format(viewDDLQuery, leafViewName2, thirdLevelViewName)); - try (PhoenixConnection phoenixConnection = - DriverManager.getConnection(getUrl(), props).unwrap(PhoenixConnection.class); - Table catalogOrChildTable = phoenixConnection.getQueryServices().getTable( + try (PhoenixMonitoredConnection phoenixConnection = + DriverManager.getConnection(getUrl(), props).unwrap(PhoenixMonitoredConnection.class); + Table catalogOrChildTable = phoenixConnection.getQueryServices().getTable( SchemaUtil.getPhysicalName(catalogOrChildTableName.toBytes(), phoenixConnection.getQueryServices().getProps()).getName())) { @@ -135,7 +135,7 @@ public void testHasChildViewsInTenantViewCase() throws Exception { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Properties tenantProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); tenantProps.setProperty(TENANT_ID_ATTRIB, tenantId); - TableName catalogOrChildTableName = ViewUtil.getSystemTableForChildLinks(0, config); + TableName catalogOrChildTableName = ViewUtil.getSystemTableForChildLinks(0, getConfiguration()); String schema = generateUniqueName(); byte[] schemaInBytes = schema.getBytes(StandardCharsets.UTF_8); byte[] tenantIdInBytes = tenantId.getBytes(StandardCharsets.UTF_8); @@ -157,7 +157,7 @@ public void testHasChildViewsInTenantViewCase() throws Exception { String viewIndexDDL = "CREATE INDEX " + tenantViewIndex + " ON " + tenantViewOnMultiTenantTable2 + "(NUM DESC) INCLUDE (ID)"; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute(multiTenantTableDDL); conn.createStatement().execute(globalViewDDL); @@ -173,9 +173,9 @@ public void testHasChildViewsInTenantViewCase() throws Exception { tenantConn.createStatement().execute(viewIndexDDL); } - try (PhoenixConnection phoenixConnection = DriverManager.getConnection(getUrl(), - props).unwrap(PhoenixConnection.class); - Table catalogOrChildTable = phoenixConnection.getQueryServices().getTable( + try (PhoenixMonitoredConnection phoenixConnection = DriverManager.getConnection(getUrl(), + props).unwrap(PhoenixMonitoredConnection.class); + Table catalogOrChildTable = phoenixConnection.getQueryServices().getTable( SchemaUtil.getPhysicalName(catalogOrChildTableName.toBytes(), phoenixConnection.getQueryServices().getProps()).getName())) { @@ -211,7 +211,7 @@ public void testHasChildViewsInTenantViewCase() throws Exception { @Test public void testFindAllRelativesForGlobalConnection() throws Exception { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - TableName catalogOrChildTableName = ViewUtil.getSystemTableForChildLinks(0, config); + TableName catalogOrChildTableName = ViewUtil.getSystemTableForChildLinks(0, getConfiguration()); String schema = generateUniqueName(); byte[] schemaInBytes = schema.getBytes(StandardCharsets.UTF_8); byte[] tenantIdInBytes = new byte[0]; @@ -234,8 +234,8 @@ public void testFindAllRelativesForGlobalConnection() throws Exception { conn.createStatement().execute( String.format(viewDDLQuery, leafViewName2, middleLevelViewName)); - try (PhoenixConnection phoenixConnection = DriverManager.getConnection(getUrl(), - props).unwrap(PhoenixConnection.class); + try (PhoenixMonitoredConnection phoenixConnection = DriverManager.getConnection(getUrl(), + props).unwrap(PhoenixMonitoredConnection.class); Table catalogOrChildTable = phoenixConnection.getQueryServices().getTable( SchemaUtil.getPhysicalName(catalogOrChildTableName.toBytes(), phoenixConnection.getQueryServices().getProps()).getName())) { @@ -280,7 +280,7 @@ public void testFindAllRelativesForTenantConnection() throws Exception { String tenantId2 = generateUniqueName(); Properties tenantProps2 = PropertiesUtil.deepCopy(TEST_PROPERTIES); tenantProps2.setProperty(TENANT_ID_ATTRIB, tenantId2); - TableName catalogOrChildTableName = ViewUtil.getSystemTableForChildLinks(0, config); + TableName catalogOrChildTableName = ViewUtil.getSystemTableForChildLinks(0 , getConfiguration()); String schema = generateUniqueName(); byte[] schemaInBytes = schema.getBytes(StandardCharsets.UTF_8); byte[] tenantId1InBytes = tenantId1.getBytes(StandardCharsets.UTF_8); @@ -313,9 +313,9 @@ public void testFindAllRelativesForTenantConnection() throws Exception { String.format(viewDDL, tenant2LeafViewName, multiTenantTableName)); } - try (PhoenixConnection phoenixConnection = DriverManager.getConnection(getUrl(), - props).unwrap(PhoenixConnection.class); - Table catalogOrChildTable = phoenixConnection.getQueryServices().getTable( + try (PhoenixMonitoredConnection phoenixConnection = DriverManager.getConnection(getUrl(), + props).unwrap(PhoenixMonitoredConnection.class); + Table catalogOrChildTable = phoenixConnection.getQueryServices().getTable( SchemaUtil.getPhysicalName(catalogOrChildTableName.toBytes(), phoenixConnection.getQueryServices().getProps()).getName())) { @@ -358,14 +358,14 @@ public void testFindLegitChildViews() throws Exception { childViewNames.add("A_" + generateUniqueName()); childViewNames.add("B_" + generateUniqueName()); childViewNames.add("C_" + generateUniqueName()); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute(String.format(CREATE_BASE_TABLE_DDL, BASE_TABLE_SCHEMA, parentTable)); for (String childViewName : childViewNames) { conn.createStatement().execute(String.format(CREATE_CHILD_VIEW_LEVEL_1_DDL, CHILD_VIEW_LEVEL_1_SCHEMA, childViewName, BASE_TABLE_SCHEMA, parentTable)); } - ConnectionQueryServices cqs = conn.unwrap(PhoenixConnection.class).getQueryServices(); + ConnectionQueryServices cqs = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); try (Table childLinkTable = cqs.getTable(SchemaUtil.getPhysicalName( SYSTEM_LINK_HBASE_TABLE_NAME.toBytes(), cqs.getProps()).getName())) { Pair, List> allDescendants = @@ -408,9 +408,8 @@ public void testOrphanViewDetection() throws Exception { final String viewName = "V_" + generateUniqueName(); createOrphanLink(BASE_TABLE_SCHEMA, parent1TableName, parent2TableName, CHILD_VIEW_LEVEL_1_SCHEMA, viewName); - - try (Connection conn = DriverManager.getConnection(getUrl())) { - ConnectionQueryServices cqs = conn.unwrap(PhoenixConnection.class).getQueryServices(); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { + ConnectionQueryServices cqs = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); try (Table childLinkTable = cqs.getTable(SchemaUtil.getPhysicalName( SYSTEM_LINK_HBASE_TABLE_NAME.toBytes(), cqs.getProps()).getName())) { // The view is a legitimate child of parent1, so it should not be counted as @@ -443,19 +442,19 @@ public void testOrphanViewDetection() throws Exception { } /** - * Test {@link ViewUtil#getViewIndexIds(PhoenixConnection, String, boolean)} for a table which is not view index and ensure it throws {@link IllegalArgumentException} + * Test {@link ViewUtil#getViewIndexIds(PhoenixMonitoredConnection, String, boolean)} for a table which is not view index and ensure it throws {@link IllegalArgumentException} * @throws IOException * @throws SQLException */ @Test(expected=IllegalArgumentException.class) public void testGetViewIndexIdsForNonViewIndexTable() throws IOException, SQLException { - try (Connection conn = DriverManager.getConnection(getUrl())) { - ViewUtil.getViewIndexIds(conn.unwrap(PhoenixConnection.class), "TEST_TABLE", true); + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { + ViewUtil.getViewIndexIds(conn.unwrap(PhoenixMonitoredConnection.class), "TEST_TABLE", true); } } /** - * Test {@link ViewUtil#getViewIndexIds(PhoenixConnection, String, boolean)} for a table with non-null schema + * Test {@link ViewUtil#getViewIndexIds(PhoenixMonitoredConnection, String, boolean)} for a table with non-null schema * @throws SQLException * @throws IOException */ @@ -465,7 +464,7 @@ public void testGetViewIndexIdsWithSchema() throws SQLException, IOException { } /** - * Test {@link ViewUtil#getViewIndexIds(PhoenixConnection, String, boolean)} for a table without schema + * Test {@link ViewUtil#getViewIndexIds(PhoenixMonitoredConnection, String, boolean)} for a table without schema * @throws SQLException * @throws IOException */ @@ -475,7 +474,7 @@ public void testGetViewIndexIdsWithoutSchema() throws SQLException, IOException } /** - * Helper method to test {@link ViewUtil#getViewIndexIds(PhoenixConnection, String, boolean)} method + * Helper method to test {@link ViewUtil#getViewIndexIds(PhoenixMonitoredConnection, String, boolean)} method * 1. Create a multi-tenant table * 2. Create 2 global views (globalViewName1 & globalViewName2) and 5 global view indexes (2 on globalViewName1 & 3 on globalViewName2) * 3. Create 2 tenant views (tenantViewName1 & tenantViewName2) and 3 tenant view indexes (1 on tenantViewName1 & 2 on tenantViewName2) @@ -512,7 +511,7 @@ private void testGetViewIndexIds(String schemaPrefix) throws IOException, SQLExc final String viewIndexDDL = "CREATE INDEX %s ON %s (NUM DESC) INCLUDE (ID)"; final String tenantViewDDL = "CREATE VIEW %s AS SELECT * FROM %s"; - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { // Create data table, global views and global view indexes conn.createStatement().execute(createTableDDL); @@ -537,11 +536,11 @@ private void testGetViewIndexIds(String schemaPrefix) throws IOException, SQLExc } // Get view indexes ids only for global view indexes (excluding tenant view indexes) - List list = ViewUtil.getViewIndexIds(conn.unwrap(PhoenixConnection.class), MetaDataUtil.getViewIndexPhysicalName(tableName), false); + List list = ViewUtil.getViewIndexIds(conn.unwrap(PhoenixMonitoredConnection.class), MetaDataUtil.getViewIndexPhysicalName(tableName), false); assertEquals(5, list.size()); // Get view indexes ids for both global and tenant view indexes - list = ViewUtil.getViewIndexIds(conn.unwrap(PhoenixConnection.class), MetaDataUtil.getViewIndexPhysicalName(tableName), true); + list = ViewUtil.getViewIndexIds(conn.unwrap(PhoenixMonitoredConnection.class), MetaDataUtil.getViewIndexPhysicalName(tableName), true); assertEquals(8, list.size()); } } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/WALAnnotationIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/WALAnnotationIT.java index 0c6999ff165..2a5b117dd96 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/WALAnnotationIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/WALAnnotationIT.java @@ -32,6 +32,7 @@ import org.apache.phoenix.execute.MutationState; import org.apache.phoenix.hbase.index.IndexRegionObserver; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.BaseTest; import org.apache.phoenix.query.PhoenixTestBuilder; import org.apache.phoenix.query.PhoenixTestBuilder.SchemaBuilder; @@ -39,6 +40,7 @@ import org.apache.phoenix.schema.PTable; import org.apache.phoenix.util.MetaDataUtil; import org.apache.phoenix.util.PhoenixRuntime; +import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.TestUtil; import org.junit.Assume; @@ -62,7 +64,9 @@ import java.util.Optional; import java.util.Properties; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CHANGE_DETECTION_ENABLED; +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.assertNotNull; @@ -94,7 +98,11 @@ public static synchronized void doSetup() throws Exception { AnnotatedWALObserver.class.getName()); props.put(IndexRegionObserver.PHOENIX_APPEND_METADATA_TO_WAL, "true"); props.put(QueryServices.ENABLE_SERVER_UPSERT_SELECT, "true"); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()), new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @Test @@ -107,7 +115,7 @@ public void testSimpleUpsertAndDelete() throws Exception { @Test public void testNoAnnotationsIfChangeDetectionDisabled() throws Exception { - try (PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl())) { + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.setAutoCommit(true); SchemaBuilder builder = new SchemaBuilder(getUrl()); SchemaBuilder.TableOptions tableOptions = getTableOptions(); @@ -150,7 +158,7 @@ public void testNoAnnotationsIfChangeDetectionDisabled() throws Exception { @Test public void testCantSetChangeDetectionOnIndex() throws Exception { - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { SchemaBuilder builder = new SchemaBuilder(getUrl()); builder.withTableDefaults().build(); try { @@ -182,7 +190,7 @@ public void testUpsertAndDeleteWithGlobalIndex() throws Exception { // "base" table data they index. private String upsertAndDeleteHelper(SchemaBuilder builder, boolean createGlobalIndex) throws Exception { - try (PhoenixConnection conn = getConnection()) { + try (PhoenixMonitoredConnection conn = getConnection()) { SchemaBuilder.TableOptions tableOptions = getTableOptions(); if (createGlobalIndex) { @@ -223,7 +231,7 @@ private SchemaBuilder.TableOptions getTableOptions() { @Test public void testUpsertSelectClientSide() throws Exception { - try (PhoenixConnection conn = getConnection()) { + try (PhoenixMonitoredConnection conn = getConnection()) { SchemaBuilder baseBuilder = new SchemaBuilder(getUrl()); SchemaBuilder targetBuilder = new SchemaBuilder(getUrl()); //upsert selecting from a different table will force processing to be client-side @@ -242,7 +250,7 @@ public void testUpsertSelectClientSide() throws Exception { } } - private void verifyBaseAndTargetAnnotations(PhoenixConnection conn, SchemaBuilder baseBuilder, + private void verifyBaseAndTargetAnnotations(PhoenixMonitoredConnection conn, SchemaBuilder baseBuilder, SchemaBuilder targetBuilder, int expectedAnnotations) throws SQLException, IOException { PTable baseTable = conn.getTableNoCache(baseBuilder.getEntityTableName()); @@ -255,7 +263,7 @@ private void verifyBaseAndTargetAnnotations(PhoenixConnection conn, SchemaBuilde public void testUpsertSelectServerSide() throws Exception { Assume.assumeFalse(isImmutable); //only mutable tables can be processed server-side SchemaBuilder targetBuilder = new SchemaBuilder(getUrl()); - try (PhoenixConnection conn = getConnection()) { + try (PhoenixMonitoredConnection conn = getConnection()) { targetBuilder.withTableOptions(getTableOptions()).build(); conn.createStatement().execute("UPSERT INTO " + targetBuilder.getEntityTableName() + " " + "VALUES" + @@ -279,7 +287,7 @@ public void testGroupedUpsertSelect() throws Exception { // processed client-side SchemaBuilder baseBuilder = new SchemaBuilder(getUrl()); SchemaBuilder targetBuilder = new SchemaBuilder(getUrl()); - try (PhoenixConnection conn = getConnection()) { + try (PhoenixMonitoredConnection conn = getConnection()) { baseBuilder.withTableOptions(getTableOptions()).build(); targetBuilder.withTableOptions(getTableOptions()).build(); conn.createStatement().execute("UPSERT INTO " + baseBuilder.getEntityTableName() + " VALUES" + @@ -304,7 +312,7 @@ public void testRangeDeleteServerSide() throws Exception { private void testRangeDeleteHelper(boolean isClientSide) throws Exception { SchemaBuilder builder = new SchemaBuilder(getUrl()); builder.withTableOptions(getTableOptions()).build(); - try (PhoenixConnection conn = getConnection()) { + try (PhoenixMonitoredConnection conn = getConnection()) { conn.createStatement().execute("UPSERT INTO " + builder.getEntityTableName() + " VALUES ('a', 'b', '2', 'bc', '3')"); conn.commit(); @@ -334,7 +342,7 @@ public void testRangeDeleteClientSide() throws Exception { @Test public void testGlobalViewUpsert() throws Exception { SchemaBuilder builder = new SchemaBuilder(getUrl()); - try (PhoenixConnection conn = getConnection()) { + try (PhoenixMonitoredConnection conn = getConnection()) { createGlobalViewHelper(builder, conn); conn.createStatement().execute("UPSERT INTO " + builder.getEntityGlobalViewName() + " VALUES" + " ('a', '" + PhoenixTestBuilder.DDLDefaults.DEFAULT_KP + @@ -351,7 +359,7 @@ public void testGlobalViewUpsert() throws Exception { } - private void createGlobalViewHelper(SchemaBuilder builder, PhoenixConnection conn) throws Exception { + private void createGlobalViewHelper(SchemaBuilder builder, PhoenixMonitoredConnection conn) throws Exception { builder.withTableOptions(getTableOptions()). withGlobalViewOptions(getGlobalViewOptions(builder)).build(); PTable view = conn.getTableNoCache(builder.getEntityGlobalViewName()); @@ -377,10 +385,10 @@ private void tenantViewHelper(boolean createIndex) throws Exception { // child tenant view. Make sure that the annotations use the tenant view name String tenant = generateUniqueName(); SchemaBuilder builder = new SchemaBuilder(getUrl()); - try (PhoenixConnection conn = getConnection()) { + try (PhoenixMonitoredConnection conn = getConnection()) { createGlobalViewHelper(builder, conn); } - try (PhoenixConnection conn = (PhoenixConnection) getTenantConnection(tenant)) { + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) getTenantConnection(tenant)) { SchemaBuilder.DataOptions dataOptions = builder.getDataOptions(); dataOptions.setTenantId(tenant); if (createIndex) { @@ -428,7 +436,7 @@ public void testTenantViewUpsertWithIndex() throws Exception { public void testOnDuplicateUpsertWithIndex() throws Exception { Assume.assumeFalse(this.isImmutable); // on duplicate is not supported for immutable tables SchemaBuilder builder = new SchemaBuilder(getUrl()); - try (PhoenixConnection conn = getConnection()) { + try (PhoenixMonitoredConnection conn = getConnection()) { SchemaBuilder.TableOptions tableOptions = getTableOptions(); builder.withTableOptions(tableOptions).withTableIndexDefaults().build(); PTable table = conn.getTableNoCache(builder.getEntityTableName()); @@ -492,14 +500,14 @@ private void assertAnnotation(int numOccurrences, String physicalTableName, assertEquals(0, notFoundCount); } - private PhoenixConnection getConnection() throws SQLException { - Properties props = new Properties(); + private PhoenixMonitoredConnection getConnection() throws SQLException { + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.toString(false)); - return (PhoenixConnection) DriverManager.getConnection(getUrl(), props); + return (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), props); } private Connection getTenantConnection(String tenant) throws SQLException { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenant); props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.toString(false)); return DriverManager.getConnection(getUrl(), props); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/BaseIndexWithRegionMovesIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/BaseIndexWithRegionMovesIT.java index eaa2b932776..e4a04bad856 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/BaseIndexWithRegionMovesIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/BaseIndexWithRegionMovesIT.java @@ -37,6 +37,7 @@ import org.apache.phoenix.end2end.ParallelStatsDisabledWithRegionMovesIT; import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixPreparedStatement; import org.apache.phoenix.jdbc.PhoenixResultSet; import org.apache.phoenix.jdbc.PhoenixStatement; @@ -91,7 +92,6 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.junit.Assume.assumeFalse; - @RunWith(Parameterized.class) public abstract class BaseIndexWithRegionMovesIT extends ParallelStatsDisabledWithRegionMovesIT { private static final Random RAND = new Random(); @@ -1027,7 +1027,7 @@ public void testUpsertAfterIndexDrop() throws Exception { conn.commit(); // the index table is one row - Table table = conn.unwrap(PhoenixConnection.class).getQueryServices() + Table table = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices() .getTable(fullTableName.getBytes()); ResultScanner resultScanner = table.getScanner(new Scan()); for (Result result : resultScanner) { @@ -1195,7 +1195,7 @@ public void testIndexWithCaseSensitiveCols() throws Exception { tableDDLOptions); query = "SELECT * FROM " + fullTableName; rs = conn.createStatement().executeQuery(query); - long ts = conn.unwrap(PhoenixConnection.class) + long ts = conn.unwrap(PhoenixMonitoredConnection.class) .getTable(new PTableKey(null, fullTableName)).getTimeStamp(); assertFalse(rs.next()); conn.createStatement().execute( @@ -1325,7 +1325,7 @@ public void testIndexWithCaseSensitiveCols() throws Exception { private void assertNoIndexDeletes(Connection conn, long minTimestamp, String fullIndexName) throws IOException, SQLException { if (!this.mutable) { - PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pconn = conn.unwrap(PhoenixMonitoredConnection.class); PTable index = pconn.getTable(new PTableKey(null, fullIndexName)); byte[] physicalIndexTable = index.getPhysicalName().getBytes(); try (Table hIndex = pconn.getQueryServices().getTable(physicalIndexTable)) { @@ -1478,16 +1478,16 @@ private static void assertShadowCells(Connection conn, String fullTableName, String fullIndexName, boolean exists) throws Exception { PTable ptable = - conn.unwrap(PhoenixConnection.class).getTable(new PTableKey(null, fullTableName)); + conn.unwrap(PhoenixMonitoredConnection.class).getTable(new PTableKey(null, fullTableName)); int nTableKVColumns = ptable.getColumns().size() - ptable.getPKColumns().size(); - Table hTable = conn.unwrap(PhoenixConnection.class).getQueryServices() + Table hTable = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices() .getTable(Bytes.toBytes(fullTableName)); ResultScanner tableScanner = hTable.getScanner(new Scan()); Result tableResult; PTable pindex = - conn.unwrap(PhoenixConnection.class).getTable(new PTableKey(null, fullIndexName)); + conn.unwrap(PhoenixMonitoredConnection.class).getTable(new PTableKey(null, fullIndexName)); int nIndexKVColumns = pindex.getColumns().size() - pindex.getPKColumns().size(); - Table hIndex = conn.unwrap(PhoenixConnection.class).getQueryServices() + Table hIndex = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices() .getTable(Bytes.toBytes(fullIndexName)); ResultScanner indexScanner = hIndex.getScanner(new Scan()); Result indexResult; diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/BaseLocalIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/BaseLocalIndexIT.java index ec297c15959..26bc35a2bf3 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/BaseLocalIndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/BaseLocalIndexIT.java @@ -38,6 +38,8 @@ import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; @RunWith(Parameterized.class) public abstract class BaseLocalIndexIT extends BaseTest { protected boolean isNamespaceMapped; @@ -62,11 +64,16 @@ public static synchronized void doSetup() throws Exception { // generating stats for local indexes clientProps.put(QueryServices.MIN_STATS_UPDATE_FREQ_MS_ATTRIB, "120000"); clientProps.put(QueryServices.MAX_REGION_LOCATIONS_SIZE_EXPLAIN_PLAN, "2"); - setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), new ReadOnlyProps(clientProps.entrySet().iterator())); + + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(serverProps.entrySet().iterator()), new ReadOnlyProps(clientProps.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), new ReadOnlyProps(clientProps.entrySet().iterator())); + } } protected Connection getConnection() throws SQLException{ - Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.toString(isNamespaceMapped)); return DriverManager.getConnection(getUrl(),props); } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ImmutableIndexWithStatsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ImmutableIndexWithStatsIT.java index 6181c372396..23cb2061fc4 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ImmutableIndexWithStatsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ImmutableIndexWithStatsIT.java @@ -37,7 +37,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsEnabledTest.class) public class ImmutableIndexWithStatsIT extends ParallelStatsEnabledIT { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexTestUtil.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexTestUtil.java index 5d51d141c21..04feae258f6 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexTestUtil.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexTestUtil.java @@ -62,6 +62,7 @@ import org.apache.phoenix.index.PhoenixIndexBuilder; import org.apache.phoenix.index.PhoenixIndexCodec; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.ConnectionQueryServices; import org.apache.phoenix.query.QueryConstants; import org.apache.phoenix.query.QueryServicesOptions; @@ -294,8 +295,8 @@ public static void assertCoprocsNotContains(Class clazz, TableDescriptor descrip public static void assertRowsForEmptyColValue(Connection conn, String tableName, byte[] emptyValue) throws SQLException, IOException { - ConnectionQueryServices cqs = conn.unwrap(PhoenixConnection.class).getQueryServices(); - PTable pTable = conn.unwrap(PhoenixConnection.class).getTable(tableName); + ConnectionQueryServices cqs = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); + PTable pTable = conn.unwrap(PhoenixMonitoredConnection.class).getTable(tableName); Table hTable = cqs.getTable(pTable.getPhysicalName().getBytes()); byte[] emptyKeyValueCF = SchemaUtil.getEmptyColumnFamily(pTable); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/SingleCellIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/SingleCellIndexIT.java index 8ebd4f36c62..d77a00d4aab 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/SingleCellIndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/SingleCellIndexIT.java @@ -28,6 +28,7 @@ import org.apache.phoenix.end2end.ParallelStatsDisabledIT; import org.apache.phoenix.end2end.ParallelStatsDisabledTest; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixStatement; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.util.PhoenixRuntime; @@ -500,9 +501,9 @@ private void createTableAndIndex(Connection conn, String tableName, String index public static void dumpTable(String tableName) throws Exception { // this method is also used by CDCBaseIT where case sensitive tableNames are also used tableName = tableName.replaceAll("\"", ""); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { Table - hTable = conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(tableName.getBytes()); + hTable = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getTable(tableName.getBytes()); Scan scan = new Scan(); scan.setRaw(true); scan.readAllVersions(); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java index ad54f6d46b4..c7897262dde 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java @@ -63,6 +63,7 @@ import org.apache.phoenix.index.GlobalIndexChecker; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixStatement; import org.apache.phoenix.query.KeyRange; import org.apache.phoenix.query.QueryServices; @@ -82,7 +83,6 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; - @Category(NeedsOwnMiniClusterTest.class) @RunWith(Parameterized.class) public class ViewIndexIT extends SplitSystemCatalogIT { @@ -153,14 +153,14 @@ public void testDroppingColumnWhileCreatingIndex() throws Exception { } } - private PhoenixConnection getConnection() throws SQLException{ - Properties props = new Properties(); + private PhoenixMonitoredConnection getConnection() throws SQLException{ + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.toString(isNamespaceMapped)); - return (PhoenixConnection) DriverManager.getConnection(getUrl(),props); + return (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(),props); } private Connection getTenantConnection(String tenant) throws SQLException { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenant); props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, Boolean.toString(isNamespaceMapped)); return DriverManager.getConnection(getUrl(),props); @@ -307,7 +307,7 @@ private void testCoprocsOnGlobalViewIndexHelper(boolean multiTenant, boolean mut String baseTable = generateUniqueName(); String globalView = generateUniqueName(); String globalViewIdx = generateUniqueName(); - try (PhoenixConnection conn = getConnection()) { + try (PhoenixMonitoredConnection conn = getConnection()) { createBaseTable(conn, schemaName, baseTable, multiTenant, null, null, mutable); createView(conn, schemaName, globalView, baseTable); createViewIndex(conn, schemaName, globalViewIdx, globalView, "K1"); @@ -330,13 +330,13 @@ public void testMultiTenantViewGlobalIndex() throws Exception { String globalViewIdx = generateUniqueName(); String tenantView = generateUniqueName(); String fullIndexName = SchemaUtil.getTableName(SCHEMA2, globalViewIdx); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute("CREATE TABLE " + baseTable + " (TENANT_ID CHAR(15) NOT NULL, PK2 DATE NOT NULL, PK3 INTEGER NOT NULL, KV1 VARCHAR, KV2 VARCHAR, KV3 CHAR(15) CONSTRAINT PK PRIMARY KEY(TENANT_ID, PK2, PK3)) MULTI_TENANT=true"); conn.createStatement().execute("CREATE VIEW " + fullGlobalViewName + " AS SELECT * FROM " + baseTable); conn.createStatement().execute("CREATE INDEX " + globalViewIdx + " ON " + fullGlobalViewName + " (PK3 DESC, KV3) INCLUDE (KV1) ASYNC"); String tenantId = "tenantId"; - Properties tenantProps = new Properties(); + Properties tenantProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); // create a tenant specific view try (Connection tenantConn = DriverManager.getConnection(getUrl(), tenantProps)) { @@ -426,7 +426,7 @@ public void testRowKeyComposition() throws Exception { String text2 ="text2"; BigDecimal double1 = BigDecimal.valueOf(254.564); IndexRegionObserver.setFailPostIndexUpdatesForTesting(true); - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { // View fixed, index variable createTableForRowKeyTestsAndVerify(conn, "DATE_TIME1, INT1", "TEXT1", "INT1", int1); createTableForRowKeyTestsAndVerify(conn, "DATE_TIME1, INT1, TEXT4", "TEXT1", "INT1", int1); @@ -682,7 +682,7 @@ public void testHintForIndexOnViewWithoutInclude() throws Exception { } private void testHintForIndexOnView(boolean includeColumns) throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); try (Connection conn1 = DriverManager.getConnection(getUrl(), props)) { conn1.setAutoCommit(true); String tableName = SchemaUtil.getTableName(SCHEMA1, generateUniqueName()); @@ -755,8 +755,8 @@ public void testGlobalAndTenantViewIndexesHaveDifferentIndexIds() throws Excepti String tenantViewName = "TV_" + generateUniqueName(); String globalViewIndexName = "GV_" + generateUniqueName(); String tenantViewIndexName = "TV_" + generateUniqueName(); - try(PhoenixConnection globalConn = getConnection(); - PhoenixConnection tenantConn = (PhoenixConnection) getTenantConnection(TENANT1)) { + try(PhoenixMonitoredConnection globalConn = getConnection(); + PhoenixMonitoredConnection tenantConn = (PhoenixMonitoredConnection) getTenantConnection(TENANT1)) { createBaseTable(globalConn, SCHEMA1, tableName, true, 0, null, true); createView(globalConn, SCHEMA1, globalViewName, tableName); createViewIndex(globalConn, SCHEMA1, globalViewIndexName, globalViewName, "v1"); @@ -831,7 +831,7 @@ public void testIndexIdDataTypeDefaultValue() throws Exception { @Test public void testCreateViewSchemaVersion() throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); final String schemaName = generateUniqueName(); final String tableName = generateUniqueName(); final String viewName = generateUniqueName(); @@ -839,7 +839,7 @@ public void testCreateViewSchemaVersion() throws Exception { final String dataTableFullName = SchemaUtil.getTableName(schemaName, tableName); final String viewFullName = SchemaUtil.getTableName(schemaName, viewName); final String viewIndexFullName = SchemaUtil.getTableName(schemaName, viewIndexName); - try (PhoenixConnection conn = (PhoenixConnection) DriverManager.getConnection(getUrl(), + try (PhoenixMonitoredConnection conn = (PhoenixMonitoredConnection) DriverManager.getConnection(getUrl(), props)) { String version = "V1.0"; CreateTableIT.testCreateTableSchemaVersionAndTopicNameHelper(conn, schemaName, tableName, version, null); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/join/BaseJoinIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/join/BaseJoinIT.java index c800bd4570e..94850990090 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/join/BaseJoinIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/join/BaseJoinIT.java @@ -161,7 +161,7 @@ private void createTable(Connection conn, String virtualName, String realName) t @Before public void createSchema() throws SQLException { - Connection conn = DriverManager.getConnection(getUrl()); + Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)); try { schemaName = "S_" + generateUniqueName(); seqName = "SEQ_" + generateUniqueName(); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/salted/SaltedTableMergeBucketsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/salted/SaltedTableMergeBucketsIT.java index 01fc614836d..cf9e034f67c 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/salted/SaltedTableMergeBucketsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/salted/SaltedTableMergeBucketsIT.java @@ -56,7 +56,6 @@ import org.apache.phoenix.util.TestUtil; import org.junit.Test; import org.junit.experimental.categories.Category; - @Category(ParallelStatsEnabledTest.class) public class SaltedTableMergeBucketsIT extends ParallelStatsEnabledIT { @@ -175,8 +174,7 @@ private void testIntDecIntPK(String tableName, long nowTime, SortOrder[] sortOrd private void assertExpectedWithWhere(String testType, String testSQL, Set expectedSet, int expectedCount) throws SQLException { String context = "sql: " + testSQL + ", type: " + testType; - - try (Connection tenantConnection = DriverManager.getConnection(getUrl())) { + try (Connection tenantConnection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { // perform the query ResultSet rs = tenantConnection.createStatement().executeQuery(testSQL); for (int i = 0; i < expectedCount; i++) { @@ -192,7 +190,7 @@ private void assertExpectedWithWhere(String testType, String testSQL, Set regions = admin.getRegions(TableName.valueOf(testTableName)); for (int i = 0; i < regions.size() - 1; i += 2) { @@ -300,7 +298,7 @@ private long createTableCase1(String baseTable, int saltBuckets, PDataType pkTyp String pkType2Str = getType(pkType2); String pkType3Str = getType(pkType3); - try (Connection tenantConnection = DriverManager.getConnection(getUrl())) { + try (Connection tenantConnection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { try (Statement cstmt = tenantConnection.createStatement()) { String TABLE_TEMPLATE = "CREATE TABLE IF NOT EXISTS %s(ID1 %s not null,ID2 %s not null, " @@ -335,8 +333,7 @@ private long createTableCase1(String baseTable, int saltBuckets, PDataType pkTyp "UPSERT INTO %s(ID1, ID2, ID3, ROW_ID, V) VALUES (%d, %f, %d, '%s', '%s')", baseTable, nowTime + i, 10.0, 13, "row" + i, "v" + i)); } - - try (Connection tenantConnection = DriverManager.getConnection(getUrl())) { + try (Connection tenantConnection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { tenantConnection.setAutoCommit(true); try (Statement ustmt = tenantConnection.createStatement()) { for (String upsertSql : UPSERT_SQLS) { @@ -357,7 +354,7 @@ private void createTableCase2(String baseTable, int saltBuckets, PDataType pkTyp String pkType3Str = getType(pkType3); String pkType4Str = getType(pkType4); - try (Connection globalConnection = DriverManager.getConnection(getUrl())) { + try (Connection globalConnection = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { try (Statement cstmt = globalConnection.createStatement()) { String TABLE_TEMPLATE = "CREATE TABLE IF NOT EXISTS %s(PK1 %s not null,PK2 %s not null, " @@ -368,8 +365,7 @@ private void createTableCase2(String baseTable, int saltBuckets, PDataType pkTyp pk4Order.name(), saltBuckets)); } } - - try (Connection conn = DriverManager.getConnection(getUrl())) { + try (Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES))) { conn.createStatement().execute("UPSERT INTO " + baseTable + " VALUES (1,8,10,20,30)"); conn.createStatement().execute("UPSERT INTO " + baseTable + " VALUES (1,8,11,21,31)"); conn.createStatement().execute("UPSERT INTO " + baseTable + " VALUES (1,9,5 ,22,32)"); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/salted/SaltedTableWithParallelStatsEnabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/salted/SaltedTableWithParallelStatsEnabledIT.java index d5149554adf..601c65db6af 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/salted/SaltedTableWithParallelStatsEnabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/salted/SaltedTableWithParallelStatsEnabledIT.java @@ -28,8 +28,10 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.phoenix.end2end.ParallelStatsEnabledIT; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.SaltingUtil; +import org.apache.phoenix.util.PropertiesUtil; import org.junit.Test; import org.junit.Assert; import org.junit.experimental.categories.Category; @@ -48,6 +50,7 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; @Category(ParallelStatsEnabledIT.class) @RunWith(Parameterized.class) @@ -88,7 +91,7 @@ public void testPhoenix7580() throws Exception { int pointLookupsPerSaltBkt = pk2ValuesForPointLookups.length / saltBucketCount; String connProfile = "testRangeScanForPhoenix7580" + withStatsForParallelization; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(QueryServices.USE_STATS_FOR_PARALLELIZATION, withStatsForParallelization ? Boolean.TRUE.toString() : Boolean.FALSE.toString()); try (Connection conn = DriverManager.getConnection(getUrl(connProfile), props)) { @@ -144,7 +147,7 @@ private void assertRangeScanRowCntFromHBaseAndPhoenix(Connection conn, int expec String tableName, int saltBucketCount, String primaryKeyPrefix) throws Exception { - Table hTable = conn.unwrap(PhoenixConnection.class) + Table hTable = conn.unwrap(PhoenixMonitoredConnection.class) .getQueryServices().getTable(tableName.getBytes()); int rowCountFromHBase = 0; byte[] rowKeyPrefix = new byte[primaryKeyPrefix.length() + 1]; @@ -176,7 +179,7 @@ private void assertRangeScanRowCntFromHBaseAndPhoenix(Connection conn, int expec private void assertFullScanRowCntFromHBaseAndPhoenix(Connection conn, int expectedRowCount, String tableName) throws Exception { - Table hTable = conn.unwrap(PhoenixConnection.class) + Table hTable = conn.unwrap(PhoenixMonitoredConnection.class) .getQueryServices().getTable(tableName.getBytes()); int rowCountFromHBase = 0; Scan scan = new Scan(); @@ -205,7 +208,7 @@ private void assertPointLookupsRowCntFromHBaseAndPhoenix(Connection conn, int ex throws Exception { String secondPrimaryKeyPrefix = "pk2_"; String primaryKeyPrefix = firstPrimaryKey + secondPrimaryKeyPrefix; - Table hTable = conn.unwrap(PhoenixConnection.class) + Table hTable = conn.unwrap(PhoenixMonitoredConnection.class) .getQueryServices().getTable(tableName.getBytes()); int rowCountFromHBase = 0; byte[] rowKey = new byte[primaryKeyPrefix.length() + 3]; @@ -263,7 +266,7 @@ private void triggerPhoenix7580(Connection conn, String tableName, int saltBucke // Save this and will be used to verify that conditions to trigger PHOENIX-7580 are // being met at the end of this method call. expectedEndKeyPrefixAfterSplit = Bytes.copy(rowKeyPrefix); - Table hTable = conn.unwrap(PhoenixConnection.class) + Table hTable = conn.unwrap(PhoenixMonitoredConnection.class) .getQueryServices().getTable(tableName.getBytes()); Scan scan = new Scan(); scan.setRowPrefixFilter(rowKeyPrefix); @@ -283,7 +286,7 @@ private void triggerPhoenix7580(Connection conn, String tableName, int saltBucke } // Identify region corresponding to the second last salt bucket for splitting - Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin(); + Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin(); List regions = admin.getRegions(TableName.valueOf(tableName)); RegionInfo secondLastSaltBucketRegion = null; for (RegionInfo regionInfo : regions) { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/jdbc/HighAvailabilityTestingUtility.java b/phoenix-core/src/it/java/org/apache/phoenix/jdbc/HighAvailabilityTestingUtility.java index 691adb97758..1fa35377f45 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/jdbc/HighAvailabilityTestingUtility.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/jdbc/HighAvailabilityTestingUtility.java @@ -32,6 +32,9 @@ import org.apache.hadoop.hbase.replication.ReplicationPeerConfig; import org.apache.phoenix.hbase.index.util.IndexManagementUtil; import org.apache.phoenix.jdbc.ClusterRoleRecord.ClusterRole; +import org.apache.phoenix.util.PropertiesUtil; +import org.apache.phoenix.util.ReadOnlyProps; +import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,6 +47,7 @@ import java.sql.Statement; import java.util.Arrays; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.Properties; import java.util.concurrent.Executors; @@ -66,6 +70,7 @@ import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_MASTER; import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_RPC; import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_ZK; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -96,10 +101,14 @@ public static class HBaseTestingUtilityPair implements Closeable { static final String PRINCIPAL = "USER_FOO"; public HBaseTestingUtilityPair() { + this(new ReadOnlyProps()); + } + + public HBaseTestingUtilityPair(ReadOnlyProps overrideProps) { Configuration conf1 = hbaseCluster1.getConfiguration(); Configuration conf2 = hbaseCluster2.getConfiguration(); - setUpDefaultHBaseConfig(conf1); - setUpDefaultHBaseConfig(conf2); + setUpDefaultHBaseConfig(conf1, overrideProps); + setUpDefaultHBaseConfig(conf2, overrideProps); } /** @@ -107,9 +116,9 @@ public HBaseTestingUtilityPair() { * * @throws Exception if fails to start either cluster */ - public void start() throws Exception { - hbaseCluster1.startMiniCluster(); - hbaseCluster2.startMiniCluster(); + public void start(int num) throws Exception { + hbaseCluster1.startMiniCluster(num); + hbaseCluster2.startMiniCluster(num); /* Note that in hbase2 testing utility these give inconsistent results, one gives ip other gives localhost @@ -119,9 +128,11 @@ public void start() throws Exception { String confAddress1 = hbaseCluster1.getConfiguration().get(HConstants.ZOOKEEPER_QUORUM); String confAddress2 = hbaseCluster2.getConfiguration().get(HConstants.ZOOKEEPER_QUORUM); + String znode1 = hbaseCluster1.getConfiguration().get(HConstants.ZOOKEEPER_ZNODE_PARENT , DEFAULT_ZOOKEEPER_ZNODE_PARENT); + String znode2 = hbaseCluster2.getConfiguration().get(HConstants.ZOOKEEPER_ZNODE_PARENT , DEFAULT_ZOOKEEPER_ZNODE_PARENT); - zkUrl1 = String.format("%s\\:%d::/hbase", confAddress1, hbaseCluster1.getZkCluster().getClientPort()); - zkUrl2 = String.format("%s\\:%d::/hbase", confAddress2, hbaseCluster2.getZkCluster().getClientPort()); + zkUrl1 = String.format("%s\\:%d::%s", confAddress1, hbaseCluster1.getZkCluster().getClientPort(), znode1); + zkUrl2 = String.format("%s\\:%d::%s", confAddress2, hbaseCluster2.getZkCluster().getClientPort(), znode2); haAdmin1 = new PhoenixHAAdmin(getZkUrl1(), hbaseCluster1.getConfiguration(), HighAvailibilityCuratorProvider.INSTANCE); haAdmin2 = new PhoenixHAAdmin(getZkUrl2(), hbaseCluster2.getConfiguration(), HighAvailibilityCuratorProvider.INSTANCE); @@ -140,6 +151,9 @@ public void start() throws Exception { getZkUrl1(), getZkUrl2()); logClustersStates(); } + public void start() throws Exception { + start(0); + } /** * Get Specific url of specific cluster based on index and registryType @@ -532,12 +546,12 @@ public void createTableOnClusterPair(HighAvailabilityGroup haGroup, String table * @param replicationScope the table replication scope true=1 and false=0 * @throws SQLException if error happens */ - public void createTableOnClusterPair(HighAvailabilityGroup haGroup, String tableName, boolean replicationScope) + public void createTableOnClusterPair(HighAvailabilityGroup haGroup, String tableName, boolean replicationScope, Properties props) throws SQLException { for (String url : Arrays.asList(getURL(1, haGroup.getRoleRecord().getRegistryType()), getURL(2, haGroup.getRoleRecord().getRegistryType()))) { String jdbcUrl = getJdbcUrl(haGroup, url); - try (Connection conn = DriverManager.getConnection(jdbcUrl, new Properties())) { + try (Connection conn = DriverManager.getConnection(jdbcUrl, props)) { conn.createStatement().execute(String.format( "CREATE TABLE IF NOT EXISTS %s (\n" + "id INTEGER PRIMARY KEY,\n" @@ -553,12 +567,17 @@ public void createTableOnClusterPair(HighAvailabilityGroup haGroup, String table which otherwise short circuits the table creation on the 2nd call As the 2 region servers share a jvm */ - ((PhoenixConnection) conn).getQueryServices().clearCache(); + ((PhoenixMonitoredConnection) conn).getQueryServices().clearCache(); } } LOG.info("Created table {} on cluster pair {}", tableName, this); } + public void createTableOnClusterPair(HighAvailabilityGroup haGroup, String tableName, boolean replicationScope) + throws SQLException { + createTableOnClusterPair(haGroup, tableName, replicationScope, PropertiesUtil.deepCopy(TEST_PROPERTIES)); + } + /** * Create multi-tenant table and view with randomly generated table name. * @@ -653,7 +672,7 @@ public String toString() { } /** Sets up the default HBase configuration for Phoenix HA testing. */ - private static void setUpDefaultHBaseConfig(Configuration conf) { + private static void setUpDefaultHBaseConfig(Configuration conf, ReadOnlyProps overrideProps) { // Set Phoenix HA timeout for ZK client to be a smaller number conf.setInt(PHOENIX_HA_ZK_CONNECTION_TIMEOUT_MS_KEY, 1000); conf.setInt(PHOENIX_HA_ZK_SESSION_TIMEOUT_MS_KEY, 1000); @@ -707,6 +726,10 @@ private static void setUpDefaultHBaseConfig(Configuration conf) { conf.set(INDEX_COMMITTER_CONF_KEY, TestTrackingParallelWriterIndexCommitter.class.getName()); + // override any defaults based on overrideProps + for (Map.Entry entry : overrideProps) { + conf.set(entry.getKey(), entry.getValue()); + } } } diff --git a/phoenix-core/src/it/java/org/apache/phoenix/query/ConnectionCachingIT.java b/phoenix-core/src/it/java/org/apache/phoenix/query/ConnectionCachingIT.java index f32b3f42c39..b5fd3ee813f 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/query/ConnectionCachingIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/query/ConnectionCachingIT.java @@ -30,6 +30,7 @@ import org.apache.phoenix.end2end.ParallelStatsEnabledIT; import org.apache.phoenix.end2end.ParallelStatsEnabledTest; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.query.ConnectionQueryServices; import org.apache.phoenix.query.ConnectionQueryServicesImpl; import org.apache.phoenix.query.DelegateConnectionQueryServices; @@ -43,7 +44,6 @@ import org.junit.runners.Parameterized.Parameters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - @Category(ParallelStatsEnabledTest.class) @RunWith(Parameterized.class) public class ConnectionCachingIT extends ParallelStatsEnabledIT { @@ -90,7 +90,7 @@ public void test() throws Exception { } long getNumCachedConnections(Connection conn) throws Exception { - PhoenixConnection pConn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pConn = conn.unwrap(PhoenixMonitoredConnection.class); ConnectionQueryServices cqs = pConn.getQueryServices(); // For whatever reason, we sometimes get a delegate here, and sometimes the real thing. if (cqs instanceof DelegateConnectionQueryServices) { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/schema/tool/SchemaToolExtractionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/schema/tool/SchemaToolExtractionIT.java index d165ffe67f0..af6f8095641 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/schema/tool/SchemaToolExtractionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/schema/tool/SchemaToolExtractionIT.java @@ -20,6 +20,7 @@ import org.apache.phoenix.end2end.ParallelStatsEnabledIT; import org.apache.phoenix.end2end.ParallelStatsEnabledTest; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.parse.ParseException; import org.apache.phoenix.parse.SQLParser; import org.apache.phoenix.schema.PTable; @@ -49,15 +50,19 @@ import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.fail; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; - @Category(ParallelStatsEnabledTest.class) public class SchemaToolExtractionIT extends ParallelStatsEnabledIT { @BeforeClass public static synchronized void setup() throws Exception { Map props = Collections.emptyMap(); - setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + setUpTestClusterForHA(new ReadOnlyProps(props.entrySet().iterator()),new ReadOnlyProps(props.entrySet().iterator())); + } else { + setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); + } } @Test @@ -136,8 +141,8 @@ public void testDDLsWithDefaults() throws Exception { List queries = new ArrayList(){}; queries.add(createTableStatement); queries.add(createIndexStatement); - try (PhoenixConnection conn = DriverManager.getConnection(getUrl(), props) - .unwrap(PhoenixConnection.class)) { + try (PhoenixMonitoredConnection conn = DriverManager.getConnection(getUrl(), props) + .unwrap(PhoenixMonitoredConnection.class)) { executeCreateStatements(conn, queries); PTable pData = conn.getTable(pTableFullName); PTable pIndex = conn.getTable(pIndexFullName); @@ -661,7 +666,7 @@ public void testSaltingWithOOOPKDefinitions() throws Exception { } private Connection getTenantConnection(String url, String tenantId) throws SQLException { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId); return DriverManager.getConnection(url, props); } @@ -696,7 +701,7 @@ private void executeCreateStatements(Connection conn, List queries) thro public static String runSchemaTool(Connection conn, String [] args) throws Exception { SchemaTool set = new SchemaTool(); if(conn!=null) { - set.setConf(conn.unwrap(PhoenixConnection.class).getQueryServices().getConfiguration()); + set.setConf(conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getConfiguration()); } int ret = set.run(args); if (ret != 0) { 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 3e9775e2166..008cafb4f24 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 @@ -19,6 +19,9 @@ import static org.apache.hadoop.hbase.coprocessor.CoprocessorHost.REGIONSERVER_COPROCESSOR_CONF_KEY; import static org.apache.phoenix.hbase.index.write.ParallelWriterIndexCommitter.NUM_CONCURRENT_INDEX_WRITER_THREADS_CONF_KEY; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.PHOENIX_HA_GROUP_ATTR; +import static org.apache.phoenix.jdbc.HighAvailabilityTestingUtility.getHighAvailibilityGroup; import static org.apache.phoenix.query.QueryConstants.MILLIS_IN_DAY; import static org.apache.phoenix.query.QueryServices.DROP_METADATA_ATTRIB; import static org.apache.phoenix.query.QueryServices.GLOBAL_INDEX_ROW_AGE_THRESHOLD_TO_DELETE_MS_ATTRIB; @@ -104,6 +107,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Optional; import java.util.Properties; import java.util.Set; import java.util.concurrent.Callable; @@ -150,8 +154,13 @@ import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.exception.SQLExceptionInfo; import org.apache.phoenix.hbase.index.util.IndexManagementUtil; +import org.apache.phoenix.jdbc.HighAvailabilityGroup; +import org.apache.phoenix.jdbc.HighAvailabilityPolicy; +import org.apache.phoenix.jdbc.HighAvailabilityTestingUtility; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; +import org.apache.phoenix.jdbc.PhoenixDriver; import org.apache.phoenix.jdbc.PhoenixEmbeddedDriver; import org.apache.phoenix.jdbc.PhoenixTestDriver; import org.apache.phoenix.schema.NewerTableAlreadyExistsException; @@ -169,6 +178,7 @@ import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.util.ServerUtil.ConnectionFactory; import org.apache.phoenix.util.TestUtil; +import org.junit.AfterClass; import org.junit.ClassRule; import org.junit.rules.TemporaryFolder; import org.slf4j.Logger; @@ -426,24 +436,65 @@ public abstract class BaseTest { protected static String getZKClientPort(Configuration conf) { return conf.get(QueryServices.ZOOKEEPER_PORT_ATTRIB); } - + private static String haGroupName; + private static HighAvailabilityGroup haGroup; protected static String url; protected static PhoenixTestDriver driver; protected static boolean clusterInitialized = false; protected static HBaseTestingUtility utility; - protected static final Configuration config = HBaseConfiguration.create(); + protected static Configuration config; + public static HighAvailabilityTestingUtility.HBaseTestingUtilityPair CLUSTERS; + private static final Logger LOG = LoggerFactory.getLogger(BaseTest.class); + @AfterClass + public static void tearDownForHA() throws Exception { + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + try { + DriverManager.deregisterDriver(PhoenixDriver.INSTANCE); + CLUSTERS.close(); + haGroup.close(); + driver.getConnectionQueryServices(CLUSTERS.getJdbcUrl1(haGroup), haGroup.getProperties()) + .close(); + driver.getConnectionQueryServices(CLUSTERS.getJdbcUrl2(haGroup), haGroup.getProperties()) + .close(); + } catch (Exception e) { + LOG.error("Fail to tear down the HA group and the CQS. Will ignore", e); + } + } + } protected static String getUrl() { if (!clusterInitialized) { throw new IllegalStateException("Cluster must be initialized before attempting to get the URL"); } + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + url = CLUSTERS.getJdbcHAUrlWithoutPrincipal()+";"+PHOENIX_TEST_DRIVER_URL_PARAM; + } return url; } + protected static String getActiveUrl() { + if (!clusterInitialized) { + throw new IllegalStateException("Cluster must be initialized before attempting to get the URL"); + } + Optional url; + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + url = haGroup.getRoleRecord().getActiveUrl(); + if (url.isPresent()) { + return url.get() + ";" + PHOENIX_TEST_DRIVER_URL_PARAM; + } else { + return CLUSTERS.getJdbcUrl1(haGroup)+";"+PHOENIX_TEST_DRIVER_URL_PARAM; + } + } + return getUrl(); + } + protected static String getUrl(String principal) throws Exception { if (!clusterInitialized) { throw new IllegalStateException("Cluster must be initialized before attempting to get the URL"); } + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + return CLUSTERS.getJdbcHAUrl(principal)+";"+PHOENIX_TEST_DRIVER_URL_PARAM; + } return getLocalClusterUrl(utility, principal); } @@ -468,7 +519,29 @@ protected static String setUpTestCluster(@Nonnull Configuration conf, ReadOnlyPr return initClusterDistributedMode(conf, overrideProps); } } - + + public static void setUpTestClusterForHA(ReadOnlyProps serverProps, ReadOnlyProps clientProps) throws Exception { + CLUSTERS = new HighAvailabilityTestingUtility.HBaseTestingUtilityPair(serverProps); //server + CLUSTERS.start(serverProps.getInt( + QueryServices.TESTS_MINI_CLUSTER_NUM_REGION_SERVERS, NUM_SLAVES_BASE)); + driver = newTestDriver(clientProps); //client + DriverManager.registerDriver(driver); + haGroupName = TEST_PROPERTIES.getProperty(PHOENIX_HA_GROUP_ATTR); + // Make first cluster ACTIVE + CLUSTERS.initClusterRole(haGroupName, HighAvailabilityPolicy.FAILOVER); + clusterInitialized = true; + Properties haGroupProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); + for (Map.Entry entry : clientProps) { + haGroupProps.setProperty(entry.getKey(), entry.getValue()); + } + haGroup = getHighAvailibilityGroup(CLUSTERS.getJdbcHAUrl(), haGroupProps); + LOG.info("Initialized haGroup {} with URL {}", haGroup, CLUSTERS.getJdbcHAUrl()); + Properties driverProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); + Connection fconn = driver.connect(getUrl(), driverProps); + fconn.close(); +// CLUSTERS.createTableOnClusterPair(haGroup, generateUniqueName()); + } + protected static void destroyDriver() { if (driver != null) { try { @@ -690,7 +763,7 @@ protected static void setPhoenixRegionServerEndpoint(Configuration conf) { private static PhoenixTestDriver newTestDriver(ReadOnlyProps props) throws Exception { PhoenixTestDriver newDriver; String driverClassName = props.get(DRIVER_CLASS_NAME_ATTRIB); - if(isDistributedClusterModeEnabled(config)) { + if(isDistributedClusterModeEnabled(getConfiguration())) { HashMap distPropMap = new HashMap<>(1); distPropMap.put(DROP_METADATA_ATTRIB, Boolean.TRUE.toString()); props = new ReadOnlyProps(props, distPropMap.entrySet().iterator()); @@ -842,7 +915,7 @@ public static String generateUniqueSequenceName() { public static void assertMetadata(Connection conn, PTable.ImmutableStorageScheme expectedStorageScheme, PTable.QualifierEncodingScheme expectedColumnEncoding, String tableName) throws Exception { - PhoenixConnection phxConn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection phxConn = conn.unwrap(PhoenixMonitoredConnection.class); PTable table = phxConn.getTableNoCache(tableName); assertEquals(expectedStorageScheme, table.getImmutableStorageScheme()); assertEquals(expectedColumnEncoding, table.getEncodingScheme()); @@ -877,13 +950,13 @@ protected static void createTestTable(String url, String ddl, byte[][] splits, L public static void createSchema(String url, String tableName, Long ts) throws SQLException { String schema = SchemaUtil.getSchemaNameFromFullName(tableName); if (!schema.equals("")) { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); if (ts != null) { props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts)); } try (Connection conn = DriverManager.getConnection(url, props);) { if (SchemaUtil.isNamespaceMappingEnabled(null, - conn.unwrap(PhoenixConnection.class).getQueryServices().getProps())) { + conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getProps())) { conn.createStatement().executeUpdate("CREATE SCHEMA IF NOT EXISTS " + schema); } } @@ -901,7 +974,7 @@ protected static void createTestTable(String url, String ddl, byte[][] splits, L buf.setCharAt(buf.length()-1, ')'); } ddl = buf.toString(); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); if (ts != null) { props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts)); } @@ -926,7 +999,7 @@ protected static byte[][] getDefaultSplits(String tenantId) { } private static void deletePriorSchemas(long ts, String url) throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.put(QueryServices.QUEUE_SIZE_ATTRIB, Integer.toString(1024)); if (ts != HConstants.LATEST_TIMESTAMP) { props.setProperty(CURRENT_SCN_ATTRIB, Long.toString(ts)); @@ -977,7 +1050,7 @@ private static void deletePriorTables(long ts, String url) throws Exception { } private static void deletePriorTables(long ts, String tenantId, String url) throws Exception { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); props.put(QueryServices.QUEUE_SIZE_ATTRIB, Integer.toString(1024)); if (ts != HConstants.LATEST_TIMESTAMP) { props.setProperty(CURRENT_SCN_ATTRIB, Long.toString(ts)); @@ -997,7 +1070,7 @@ private static void deletePriorTables(long ts, String tenantId, String url) thro rs.getString(PhoenixDatabaseMetaData.TABLE_SCHEM), rs.getString(PhoenixDatabaseMetaData.TABLE_NAME)); try { - conn.unwrap(PhoenixConnection.class).getTable(fullTableName); + conn.unwrap(PhoenixMonitoredConnection.class).getTable(fullTableName); fail("The following tables are not deleted that should be:" + getTableNames(rs)); } catch (TableNotFoundException e) { } @@ -1101,7 +1174,7 @@ protected static void initSumDoubleValues(byte[][] splits, String url) throws Ex protected static void initSumDoubleValues(String tableName, byte[][] splits, String url) throws Exception { ensureTableCreated(url, tableName, SUM_DOUBLE_NAME, splits, null); - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(url, props); try { // Insert all rows at ts @@ -1190,7 +1263,7 @@ protected static String initATableValues(String tableName, String tenantId, byte ensureTableCreated(url, tableName, tableDDLType, splits, ts-5, tableDDLOptions); } - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); if (ts != null) { props.setProperty(CURRENT_SCN_ATTRIB, Long.toString(ts-3)); } @@ -1415,7 +1488,7 @@ private static String initEntityHistoryTableValues(String tableName, String tena ensureTableCreated(url, tableName, ENTITY_HISTORY_TABLE_NAME, splits, ts-2, null); } - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); if (ts != null) { props.setProperty(CURRENT_SCN_ATTRIB, ts.toString()); } @@ -1525,7 +1598,7 @@ protected static String initSaltedEntityHistoryTableValues(String tableName, Str ensureTableCreated(url, tableName, ENTITY_HISTORY_SALTED_TABLE_NAME, splits, ts-2, null); } - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); if (ts != null) { props.setProperty(CURRENT_SCN_ATTRIB, ts.toString()); } @@ -1629,7 +1702,7 @@ protected static String initSaltedEntityHistoryTableValues(String tableName, Str */ protected static synchronized void disableAndDropNonSystemTables() throws Exception { if (driver == null) return; - Admin admin = driver.getConnectionQueryServices(getUrl(), new Properties()).getAdmin(); + Admin admin = driver.getConnectionQueryServices(getActiveUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).getAdmin(); try { List tables = admin.listTableDescriptors(); for (TableDescriptor table : tables) { @@ -1805,9 +1878,20 @@ public static void assertValuesEqualsResultSet(ResultSet rs, List> } public static HBaseTestingUtility getUtility() { + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + return CLUSTERS.getHBaseCluster1(); + } return utility; } - + + public static Configuration getConfiguration() { + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + config = CLUSTERS.getHBaseCluster1().getConfiguration(); + } else { + config = HBaseConfiguration.create(); + } + return config; + } public static void upsertRows(Connection conn, String fullTableName, int numRows) throws SQLException { for (int i=1; i<=numRows; ++i) { upsertRow(conn, fullTableName, i, false); @@ -1932,7 +2016,7 @@ protected static void verifySequenceValue(String tenantID, String sequenceName, private static void verifySequence(String tenantID, String sequenceName, String sequenceSchemaName, boolean exists, long value) throws SQLException { - PhoenixConnection phxConn = DriverManager.getConnection(getUrl()).unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection phxConn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixMonitoredConnection.class); String ddl = "SELECT " + PhoenixDatabaseMetaData.TENANT_ID + "," + PhoenixDatabaseMetaData.SEQUENCE_SCHEMA + "," @@ -1999,7 +2083,7 @@ protected static boolean regionContainsMetadataRows(RegionInfo regionInfo, protected static void splitTable(TableName fullTableName, List splitPoints) throws Exception { Admin admin = - driver.getConnectionQueryServices(getUrl(), TestUtil.TEST_PROPERTIES).getAdmin(); + driver.getConnectionQueryServices(getActiveUrl(), TestUtil.TEST_PROPERTIES).getAdmin(); assertTrue("Needs at least two split points ", splitPoints.size() > 1); assertTrue( "Number of split points should be less than or equal to the number of region servers ", @@ -2093,7 +2177,7 @@ protected static void splitSystemCatalog(Map> tenantToTable * Ensures each region of SYSTEM.CATALOG is on a different region server */ private static void moveRegion(RegionInfo regionInfo, ServerName srcServerName, ServerName dstServerName) throws Exception { - Admin admin = driver.getConnectionQueryServices(getUrl(), TestUtil.TEST_PROPERTIES).getAdmin(); + Admin admin = driver.getConnectionQueryServices(getActiveUrl(), TestUtil.TEST_PROPERTIES).getAdmin(); HBaseTestingUtility util = getUtility(); MiniHBaseCluster cluster = util.getHBaseCluster(); HMaster master = cluster.getMaster(); diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/PhoenixTestBuilder.java b/phoenix-core/src/test/java/org/apache/phoenix/query/PhoenixTestBuilder.java index f3c2f58f8e9..c45c97cae8b 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/query/PhoenixTestBuilder.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/query/PhoenixTestBuilder.java @@ -19,6 +19,7 @@ package org.apache.phoenix.query; import org.apache.hadoop.hbase.util.Bytes; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixStatement; import org.apache.phoenix.thirdparty.com.google.common.collect.Sets; import org.apache.phoenix.thirdparty.com.google.common.collect.Table; @@ -49,6 +50,7 @@ import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.IMMUTABLE_ROWS; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SALT_BUCKETS; import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB; +import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; /** * PhoenixTestBuilder is a utility class using a Builder pattern. @@ -1118,7 +1120,7 @@ public void build() throws Exception { tableKey = new PTableKey(null, SchemaUtil.normalizeFullTableName(entityTableName)); setBaseTable( - globalConnection.unwrap(PhoenixConnection.class).getTable(tableKey)); + globalConnection.unwrap(PhoenixMonitoredConnection.class).getTable(tableKey)); } // Index on Table if (tableIndexEnabled && !tableIndexCreated) { @@ -1404,7 +1406,7 @@ Connection getPhoenixConnection(String url, Properties props) throws SQLExceptio // Connect options. public static class ConnectOptions { - Properties connectProps = new Properties(); + Properties connectProps = PropertiesUtil.deepCopy(TEST_PROPERTIES); boolean useGlobalConnectionOnly = false; boolean useTenantConnectionForGlobalView = false; diff --git a/phoenix-core/src/test/java/org/apache/phoenix/util/IndexScrutiny.java b/phoenix-core/src/test/java/org/apache/phoenix/util/IndexScrutiny.java index 57782987eaa..b77345e4368 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/util/IndexScrutiny.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/util/IndexScrutiny.java @@ -28,6 +28,7 @@ import java.util.List; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.schema.PColumn; import org.apache.phoenix.schema.PTable; import org.apache.phoenix.schema.PTableKey; @@ -38,7 +39,7 @@ public class IndexScrutiny { public static long scrutinizeIndex(Connection conn, String fullTableName, String fullIndexName) throws SQLException { - PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pconn = conn.unwrap(PhoenixMonitoredConnection.class); PTable ptable = pconn.getTable(new PTableKey(pconn.getTenantId(), fullTableName)); int tableColumnOffset = 0; List tableColumns = ptable.getColumns(); 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 233723f001b..d8e1714633a 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 @@ -17,6 +17,8 @@ */ package org.apache.phoenix.util; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.HA_GROUP_PROFILE; +import static org.apache.phoenix.jdbc.HighAvailabilityGroup.PHOENIX_HA_GROUP_ATTR; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES; import static org.apache.phoenix.query.BaseTest.generateUniqueName; import static org.apache.phoenix.query.QueryConstants.MILLIS_IN_DAY; @@ -131,7 +133,9 @@ import org.apache.phoenix.filter.RowKeyComparisonFilter; import org.apache.phoenix.filter.SingleCQKeyValueComparisonFilter; import org.apache.phoenix.filter.SingleKeyValueComparisonFilter; +import org.apache.phoenix.jdbc.HighAvailabilityTestingUtility; import org.apache.phoenix.jdbc.PhoenixConnection; +import org.apache.phoenix.jdbc.PhoenixMonitoredConnection; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; import org.apache.phoenix.jdbc.PhoenixPreparedStatement; import org.apache.phoenix.jdbc.PhoenixResultSet; @@ -309,11 +313,20 @@ private TestUtil() { public static final String JOIN_SUPPLIER_TABLE_DISPLAY_NAME = JOIN_SCHEMA + "." + JOIN_SUPPLIER_TABLE; public static final String JOIN_COITEM_TABLE_DISPLAY_NAME = JOIN_SCHEMA + "." + JOIN_COITEM_TABLE; public static final String BINARY_NAME = "BinaryTable"; - + private static Properties props_for_HA; + static { + if(Boolean.parseBoolean(System.getProperty(HA_GROUP_PROFILE))){ + props_for_HA = HighAvailabilityTestingUtility.getHATestProperties(); + props_for_HA.setProperty(PHOENIX_HA_GROUP_ATTR, "HA_GROUP_"+generateUniqueName()); + } + else{ + props_for_HA = new Properties(); + } + }; /** * Read-only properties used by all tests */ - public static final Properties TEST_PROPERTIES = new Properties() { + public static final Properties TEST_PROPERTIES = new Properties(props_for_HA) { @Override public String put(Object key, Object value) { throw new UnsupportedOperationException(); @@ -500,7 +513,7 @@ public static void compareTuples(Tuple res1, Tuple res2) } public static void clearMetaDataCache(Connection conn) throws Throwable { - PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pconn = conn.unwrap(PhoenixMonitoredConnection.class); Table htable = pconn.getQueryServices().getTable(PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME_BYTES); htable.coprocessorService(MetaDataService.class, HConstants.EMPTY_START_ROW, HConstants.EMPTY_END_ROW, new Batch.Call() { @@ -880,9 +893,9 @@ public static void doMajorCompaction(Connection conn, String tableName) throws E // We simply write a marker row, request a major compaction, and then wait until the marker // row is gone - PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); + PhoenixMonitoredConnection pconn = conn.unwrap(PhoenixMonitoredConnection.class); PTable table = pconn.getTable(new PTableKey(pconn.getTenantId(), tableName)); - ConnectionQueryServices services = conn.unwrap(PhoenixConnection.class).getQueryServices(); + ConnectionQueryServices services = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); MutationState mutationState = pconn.getMutationState(); if (table.isTransactional()) { mutationState.startTransaction(table.getTransactionProvider()); @@ -950,7 +963,7 @@ public static void createTransactionalTable(Connection conn, String tableName, S public static void dumpTable(Connection conn, TableName tableName) throws SQLException, IOException { - ConnectionQueryServices cqs = conn.unwrap(PhoenixConnection.class).getQueryServices(); + ConnectionQueryServices cqs = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); Table table = cqs.getTable(tableName.getName()); dumpTable(table); } @@ -1262,7 +1275,7 @@ public static long getRowCountFromIndex(Connection conn, String tableName, Strin public static void addCoprocessor(Connection conn, String tableName, Class coprocessorClass) throws Exception { int priority = QueryServicesOptions.DEFAULT_COPROCESSOR_PRIORITY + 100; - ConnectionQueryServices services = conn.unwrap(PhoenixConnection.class).getQueryServices(); + ConnectionQueryServices services = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); TableDescriptor descriptor = services.getTableDescriptor(Bytes.toBytes(tableName)); TableDescriptorBuilder descriptorBuilder = null; if (!descriptor.getCoprocessorDescriptors().stream().map(CoprocessorDescriptor::getClassName) @@ -1292,7 +1305,7 @@ public static void addCoprocessor(Connection conn, String tableName, Class copro } public static void removeCoprocessor(Connection conn, String tableName, Class coprocessorClass) throws Exception { - ConnectionQueryServices services = conn.unwrap(PhoenixConnection.class).getQueryServices(); + ConnectionQueryServices services = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); TableDescriptor descriptor = services.getTableDescriptor(Bytes.toBytes(tableName)); TableDescriptorBuilder descriptorBuilder = null; if (descriptor.getCoprocessorDescriptors().stream().map(CoprocessorDescriptor::getClassName) @@ -1481,27 +1494,27 @@ public static void assertTableHasVersions(Connection conn, TableName tableName, public static ColumnFamilyDescriptor getColumnDescriptor(Connection conn, TableName tableName) throws SQLException, IOException { - Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin(); + Admin admin = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices().getAdmin(); TableDescriptor td = admin.getDescriptor(tableName); return td.getColumnFamilies()[0]; } public static void assertRawRowCount(Connection conn, TableName table, int expectedRowCount) throws SQLException, IOException { - ConnectionQueryServices cqs = conn.unwrap(PhoenixConnection.class).getQueryServices(); + ConnectionQueryServices cqs = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); int count = TestUtil.getRawRowCount(cqs.getTable(table.getName())); assertEquals(expectedRowCount, count); } public static int getRawRowCount(Connection conn, TableName table) throws SQLException, IOException { - ConnectionQueryServices cqs = conn.unwrap(PhoenixConnection.class).getQueryServices(); + ConnectionQueryServices cqs = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); return TestUtil.getRawRowCount(cqs.getTable(table.getName())); } public static int getRawCellCount(Connection conn, TableName tableName, byte[] row) throws SQLException, IOException { - ConnectionQueryServices cqs = conn.unwrap(PhoenixConnection.class).getQueryServices(); + ConnectionQueryServices cqs = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); Table table = cqs.getTable(tableName.getName()); CellCount cellCount = getCellCount(table, true); return cellCount.getCellCount(Bytes.toString(row)); @@ -1524,7 +1537,7 @@ public static void assertRawCellCount(Connection conn, TableName tableName, public static void assertRowExistsAtSCN(String url, String sql, long scn, boolean shouldExist) throws SQLException { boolean rowExists = false; - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); ResultSet rs; props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(scn)); try (Connection conn = DriverManager.getConnection(url, props)) { @@ -1544,7 +1557,7 @@ public static void assertRowExistsAtSCN(String url, String sql, long scn, boolea public static void assertRowHasExpectedValueAtSCN(String url, String sql, long scn, String value) throws SQLException { - Properties props = new Properties(); + Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); ResultSet rs; props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(scn)); try (Connection conn = DriverManager.getConnection(url, props)) { @@ -1601,7 +1614,7 @@ void execute(Admin admin, RegionLocator regionLocator, int initialRegionCount) private static void executeHBaseTableRegionOperation(Connection conn, String tableName, TableOperation operation) throws Exception { - ConnectionQueryServices services = conn.unwrap(PhoenixConnection.class).getQueryServices(); + ConnectionQueryServices services = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); Configuration configuration = services.getConfiguration(); org.apache.hadoop.hbase.client.Connection hbaseConn = ConnectionFactory.createConnection(configuration); @@ -1625,7 +1638,7 @@ private static void waitForRegionChange(RegionLocator regionLocator, int initial public static List getAllTableRegions(Connection conn, String tableName) throws Exception { - ConnectionQueryServices services = conn.unwrap(PhoenixConnection.class).getQueryServices(); + ConnectionQueryServices services = conn.unwrap(PhoenixMonitoredConnection.class).getQueryServices(); Configuration configuration = services.getConfiguration(); RegionLocator regionLocator; org.apache.hadoop.hbase.client.Connection hbaseConn diff --git a/pom.xml b/pom.xml index f637d815a89..47c8299afc7 100644 --- a/pom.xml +++ b/pom.xml @@ -2042,6 +2042,76 @@ + + ha-enabled + + true + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.2.5 + + + ${ha-test-enabled} + + + org/apache/phoenix/end2end/AlterTableWithViewsIT.java + org/apache/phoenix/end2end/AppendOnlySchemaIT.java + org/apache/phoenix/end2end/AutoPartitionViewsIT.java + org/apache/phoenix/end2end/BackwardCompatibilityForSplittableSyscatIT.java + org/apache/phoenix/end2end/BackwardCompatibilityIT.java + org/apache/phoenix/end2end/BaseRowKeyMatcherTestIT.java + org/apache/phoenix/end2end/BaseViewIT.java + org/apache/phoenix/end2end/BaseViewTTLIT.java + org/apache/phoenix/end2end/CDCDefinitionIT.java + org/apache/phoenix/end2end/CDCStreamIT.java + org/apache/phoenix/end2end/ConcurrentMutationsExtendedIT.java + org/apache/phoenix/end2end/ConnectionIT.java + org/apache/phoenix/end2end/CsvBulkLoadToolIT.java + org/apache/phoenix/end2end/CursorWithRowValueConstructorIT.java + org/apache/phoenix/end2end/DefaultPhoenixMultiViewListProviderIT.java + org/apache/phoenix/end2end/GlobalConnectionTenantTableIT.java + org/apache/phoenix/end2end/IndexRebuildTaskIT.java + org/apache/phoenix/end2end/IndexRepairRegionScannerIT.java + org/apache/phoenix/end2end/IndexScrutinyToolIT.java + org/apache/phoenix/end2end/IndexScrutinyWithMaxLookbackIT.java + org/apache/phoenix/end2end/MetaDataEndpointImplIT.java + org/apache/phoenix/end2end/MetadataGetTableReadLockIT.java + org/apache/phoenix/end2end/ParameterizedIndexUpgradeToolIT.java + org/apache/phoenix/end2end/PhoenixDriverIT.java + org/apache/phoenix/end2end/PhoenixTTLToolIT.java + org/apache/phoenix/end2end/PreMatureTimelyAbortScanIt.java + org/apache/phoenix/end2end/PropertiesInSyncIT.java + org/apache/phoenix/end2end/QueryLoggerIT.java + org/apache/phoenix/end2end/QueryWithLimitIT.java + org/apache/phoenix/end2end/RegexBulkLoadToolIT.java + org/apache/phoenix/end2end/RenewLeaseIT.java + org/apache/phoenix/end2end/SyncUpdateCacheFreqIT.java + org/apache/phoenix/end2end/TenantSpecificViewIndexIT.java + org/apache/phoenix/end2end/UnnestArrayIT.java + org/apache/phoenix/end2end/UpgradeIT.java + org/apache/phoenix/end2end/UpgradeNamespaceIT.java + org/apache/phoenix/end2end/ViewTTLIT.java + org/apache/phoenix/end2end/index/BaseIndexWithRegionMovesIT.java + org/apache/phoenix/end2end/index/ViewIndexIT.java + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 3.2.5 + + ${ha-test-enabled} + + + + + + shade-and-assembly