This is an automated email from the ASF dual-hosted git repository.
yanxinyi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/master by this push:
new 7b549c9 PHOENIX-6246 : Remove flakes from PointInTimeQueryIT
(ADDENDUM)
7b549c9 is described below
commit 7b549c9c5f6e99156309f4ac7674193ddc9d6626
Author: Viraj Jasani <[email protected]>
AuthorDate: Tue Dec 8 17:26:34 2020 +0530
PHOENIX-6246 : Remove flakes from PointInTimeQueryIT (ADDENDUM)
Signed-off-by: Xinyi Yan <[email protected]>
---
.../org/apache/phoenix/end2end/BaseQueryIT.java | 35 ++++++++++++----------
.../phoenix/end2end/PointInTimeScanQueryIT.java | 15 +++++-----
2 files changed, 26 insertions(+), 24 deletions(-)
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseQueryIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseQueryIT.java
index 51c9696..ef33b93 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseQueryIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseQueryIT.java
@@ -22,23 +22,20 @@ import static
org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
+import java.sql.SQLTimeoutException;
import java.util.Collection;
import java.util.List;
import java.util.Properties;
import org.apache.phoenix.compat.hbase.HbaseCompatCapabilities;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Lists;
import org.apache.phoenix.util.PropertiesUtil;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.AfterParam;
import org.junit.runners.Parameterized.BeforeParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.phoenix.thirdparty.com.google.common.collect.Lists;
-
-
-
/**
*
* Basic tests for Phoenix JDBC implementation
@@ -46,20 +43,17 @@ import
org.apache.phoenix.thirdparty.com.google.common.collect.Lists;
*
* @since 0.1
*/
-
@RunWith(Parameterized.class)
public abstract class BaseQueryIT extends ParallelStatsDisabledIT {
protected static final String tenantId = getOrganizationId();
- protected static final String ATABLE_INDEX_NAME = "ATABLE_IDX";
- protected static final long BATCH_SIZE = 3;
protected static final String NO_INDEX = "";
protected static final String[] GLOBAL_INDEX_DDLS =
new String[] {
- "CREATE INDEX %s ON %s (a_integer DESC) INCLUDE (" + "
A_STRING, "
+ "CREATE INDEX IF NOT EXISTS %s ON %s (a_integer DESC)
INCLUDE (" + " A_STRING, "
+ " B_STRING, " + " A_DATE)",
- "CREATE INDEX %s ON %s (a_integer, a_string) INCLUDE (" +
" B_STRING, "
+ "CREATE INDEX IF NOT EXISTS %s ON %s (a_integer, a_string)
INCLUDE (" + " B_STRING, "
+ " A_DATE)",
- "CREATE INDEX %s ON %s (a_integer) INCLUDE (" + "
A_STRING, "
+ "CREATE INDEX IF NOT EXISTS %s ON %s (a_integer) INCLUDE
(" + " A_STRING, "
+ " B_STRING, " + " A_DATE)",
NO_INDEX };
protected static final String[] LOCAL_INDEX_DDLS =
@@ -100,10 +94,10 @@ public abstract class BaseQueryIT extends
ParallelStatsDisabledIT {
}
String tableDDLOptions = optionBuilder.toString();
try {
- tableName =
- initATableValues(generateUniqueName(), tenantId,
getDefaultSplits(tenantId),
- date = new Date(System.currentTimeMillis()), null,
getUrl(),
- tableDDLOptions);
+ tableName = initATableValues(generateUniqueName(), tenantId,
+ getDefaultSplits(tenantId),
+ date = new Date(System.currentTimeMillis()), null, getUrl(),
+ tableDDLOptions);
} catch (Exception e) {
LOGGER.error("Exception when creating aTable ", e);
throw e;
@@ -113,14 +107,23 @@ public abstract class BaseQueryIT extends
ParallelStatsDisabledIT {
String indexDDL =
String.format(idxDdl, indexName, tableName);
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+ props.setProperty("phoenix.query.timeoutMs", "30000");
try (Connection conn = DriverManager.getConnection(getUrl(),
props)) {
conn.createStatement().execute(indexDDL);
+ } catch (SQLTimeoutException e) {
+ LOGGER.info("Query timed out. Retrying one more time.", e);
+ try (Connection conn = DriverManager.getConnection(getUrl(),
props)) {
+ conn.createStatement().execute(indexDDL);
+ } catch (Exception ex) {
+ LOGGER.error("Exception while creating index during second
retry: "
+ + indexDDL, ex);
+ throw ex;
+ }
} catch (Exception e) {
LOGGER.error("Exception while creating index: " + indexDDL, e);
throw e;
}
}
-
}
public BaseQueryIT(String idxDdl, boolean columnEncoded, boolean
keepDeletedCells) {
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 0cdf21d..da068aa 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
@@ -88,7 +88,7 @@ public class PointInTimeScanQueryIT extends BaseQueryIT {
long timeDelta = 100;
Thread.sleep(timeDelta);
- try(Connection upsertConn = DriverManager.getConnection(url, props)) {
+ try (Connection upsertConn = DriverManager.getConnection(url, props)) {
upsertConn.setAutoCommit(true); // Test auto commit
PreparedStatement stmt = upsertConn.prepareStatement(upsertStmt);
stmt.setString(1, tenantId);
@@ -102,7 +102,7 @@ public class PointInTimeScanQueryIT extends BaseQueryIT {
+ tableName + " WHERE organization_id=? and a_integer = 5";
props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB,
Long.toString(queryTime));
- try(Connection conn = DriverManager.getConnection(getUrl(), props)) {
+ try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
PreparedStatement statement = conn.prepareStatement(query);
statement.setString(1, tenantId);
ResultSet rs = statement.executeQuery();
@@ -129,8 +129,7 @@ public class PointInTimeScanQueryIT extends BaseQueryIT {
" ENTITY_ID, " +
" A_INTEGER) " +
"VALUES (?, ?, ?)";
- try(Connection upsertConn = DriverManager.getConnection(url, props)) {
-
+ try (Connection upsertConn = DriverManager.getConnection(url, props)) {
upsertConn.setAutoCommit(true); // Test auto commit
// Insert all rows at ts
PreparedStatement stmt = upsertConn.prepareStatement(upsertStmt);
@@ -164,11 +163,11 @@ public class PointInTimeScanQueryIT extends BaseQueryIT {
statement.setString(1, tenantId);
ResultSet rs = statement.executeQuery();
List<List<Object>> expectedResultsA = Lists.newArrayList(
- Arrays.<Object>asList(2, C_VALUE),
- Arrays.<Object>asList( 3, E_VALUE));
+ Arrays.asList(2, C_VALUE),
+ Arrays.asList(3, E_VALUE));
List<List<Object>> expectedResultsB = Lists.newArrayList(
- Arrays.<Object>asList( 5, C_VALUE),
- Arrays.<Object>asList(4, B_VALUE));
+ Arrays.asList(5, C_VALUE),
+ Arrays.asList(4, B_VALUE));
// Since we're not ordering and we may be using a descending
index, we don't
// know which rows we'll get back.
assertOneOfValuesEqualsResultSet(rs, expectedResultsA,