You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by st...@apache.org on 2020/06/19 06:32:37 UTC
[phoenix] branch 4.x updated: PHOENIX-5962 Stabilize builds
This is an automated email from the ASF dual-hosted git repository.
stoty pushed a commit to branch 4.x
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/4.x by this push:
new e92ebf0 PHOENIX-5962 Stabilize builds
e92ebf0 is described below
commit e92ebf0ec73184134a39bd9a1c5f655638f8361d
Author: Richard Antal <an...@gmail.com>
AuthorDate: Thu Jun 18 12:45:45 2020 +0200
PHOENIX-5962 Stabilize builds
---
.../phoenix/end2end/IndexBuildTimestampIT.java | 131 +++++++++++----------
.../end2end/IndexScrutinyWithMaxLookbackIT.java | 16 ++-
.../phoenix/end2end/IndexToolTimeRangeIT.java | 3 +-
.../end2end/IndexVerificationOldDesignIT.java | 2 +
.../org/apache/phoenix/end2end/MaxLookbackIT.java | 6 +
.../NonParameterizedIndexScrutinyToolIT.java | 4 +
.../index/IndexVerificationOutputRepositoryIT.java | 2 +
.../index/IndexVerificationResultRepositoryIT.java | 2 +
.../phoenix/util/EnvironmentEdgeManager.java | 3 +
.../phoenix/index/VerifySingleIndexRowTest.java | 20 ++--
.../pherf/workload/MultiThreadedRunnerTest.java | 38 +++---
11 files changed, 135 insertions(+), 92 deletions(-)
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 591efd5..5153c96 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
@@ -177,73 +177,76 @@ public class IndexBuildTimestampIT extends BaseUniqueNamesOwnClusterIT {
MyClock clock3 = new MyClock(300000);
EnvironmentEdgeManager.injectEdge(clock3);
+ try {
+
+ Properties props = new Properties();
+ props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, "true");
+ props.setProperty(QueryServices.ENABLE_SERVER_SIDE_DELETE_MUTATIONS, "true");
+ Connection conn = DriverManager.getConnection(getUrl(), props);
+
+ String viewName = null;
+ if (view) {
+ viewName = generateUniqueName();
+ conn.createStatement().execute("CREATE VIEW " + viewName + " AS SELECT * FROM " +
+ dataTableName);
+ }
+ String indexName = generateUniqueName();
+ conn.createStatement().execute("CREATE " + (localIndex ? "LOCAL " : "") + " INDEX " + indexName + " on " +
+ (view ? viewName : dataTableName) + " (val) include (ts)" + (async ? "ASYNC" : ""));
- Properties props = new Properties();
- props.setProperty(QueryServices.ENABLE_SERVER_SIDE_UPSERT_MUTATIONS, "true");
- props.setProperty(QueryServices.ENABLE_SERVER_SIDE_DELETE_MUTATIONS, "true");
- Connection conn = DriverManager.getConnection(getUrl(), props);
-
- String viewName = null;
- if (view) {
- viewName = generateUniqueName();
- conn.createStatement().execute("CREATE VIEW "+ viewName + " AS SELECT * FROM " +
- dataTableName);
- }
- String indexName = generateUniqueName();
- conn.createStatement().execute("CREATE "+ (localIndex ? "LOCAL " : "") + " INDEX " + indexName + " on " +
- (view ? viewName : dataTableName) + " (val) include (ts)" + (async ? "ASYNC" : ""));
+ conn.close();
- conn.close();
+ if (async) {
+ // run the index MR job.
+ IndexToolIT.runIndexTool(true, false, null, (view ? viewName : dataTableName), indexName);
+ }
- if (async) {
- // run the index MR job.
- IndexToolIT.runIndexTool(true, false, null, (view ? viewName : dataTableName), indexName);
+ // Verify the index timestamps via Phoenix
+ String selectSql = String.format("SELECT * FROM %s WHERE val = 'abc'", (view ? viewName : dataTableName));
+ conn = DriverManager.getConnection(getUrl());
+ // assert we are pulling from index table
+ assertExplainPlan(conn, localIndex, selectSql, dataTableName, (view ? "_IDX_" + dataTableName : indexName));
+ ResultSet rs = conn.createStatement().executeQuery(selectSql);
+ assertTrue(rs.next());
+ assertTrue(rs.unwrap(PhoenixResultSet.class).getCurrentRow().getValue(0).getTimestamp() < clock2.initialTime() &&
+ rs.unwrap(PhoenixResultSet.class).getCurrentRow().getValue(0).getTimestamp() >= clock1.initialTime());
+
+ selectSql =
+ String.format("SELECT * FROM %s WHERE val = 'bcd'", (view ? viewName : dataTableName));
+ // assert we are pulling from index table
+ assertExplainPlan(conn, localIndex, selectSql, dataTableName, (view ? "_IDX_" + dataTableName : indexName));
+
+ rs = conn.createStatement().executeQuery(selectSql);
+ assertTrue(rs.next());
+ assertTrue(rs.unwrap(PhoenixResultSet.class).getCurrentRow().getValue(0).getTimestamp() < clock3.initialTime() &&
+ rs.unwrap(PhoenixResultSet.class).getCurrentRow().getValue(0).getTimestamp() >= clock2.initialTime()
+ );
+ assertFalse(rs.next());
+
+ // Verify the index timestamps via HBase
+ PTable pIndexTable = PhoenixRuntime.getTable(conn, indexName);
+ Table table = conn.unwrap(PhoenixConnection.class).getQueryServices()
+ .getTable(pIndexTable.getPhysicalName().getBytes());
+
+ Scan scan = new Scan();
+ scan.setTimeRange(clock3.initialTime(), clock3.currentTime());
+ ResultScanner scanner = table.getScanner(scan);
+ assertTrue(scanner.next() == null);
+
+
+ scan = new Scan();
+ scan.setTimeRange(clock2.initialTime(), clock3.initialTime());
+ scanner = table.getScanner(scan);
+ assertTrue(scanner.next() != null);
+
+
+ scan = new Scan();
+ scan.setTimeRange(clock1.initialTime(), clock2.initialTime());
+ scanner = table.getScanner(scan);
+ assertTrue(scanner.next() != null);
+ conn.close();
+ } finally {
+ EnvironmentEdgeManager.reset();
}
-
- // Verify the index timestamps via Phoenix
- String selectSql = String.format("SELECT * FROM %s WHERE val = 'abc'", (view ? viewName : dataTableName));
- conn = DriverManager.getConnection(getUrl());
- // assert we are pulling from index table
- assertExplainPlan(conn, localIndex, selectSql, dataTableName, (view ? "_IDX_" + dataTableName : indexName));
- ResultSet rs = conn.createStatement().executeQuery(selectSql);
- assertTrue (rs.next());
- assertTrue(rs.unwrap(PhoenixResultSet.class).getCurrentRow().getValue(0).getTimestamp() < clock2.initialTime() &&
- rs.unwrap(PhoenixResultSet.class).getCurrentRow().getValue(0).getTimestamp() >= clock1.initialTime());
-
- selectSql =
- String.format("SELECT * FROM %s WHERE val = 'bcd'", (view ? viewName : dataTableName));
- // assert we are pulling from index table
- assertExplainPlan(conn, localIndex, selectSql, dataTableName, (view ? "_IDX_" + dataTableName : indexName));
-
- rs = conn.createStatement().executeQuery(selectSql);
- assertTrue (rs.next());
- assertTrue(rs.unwrap(PhoenixResultSet.class).getCurrentRow().getValue(0).getTimestamp() < clock3.initialTime() &&
- rs.unwrap(PhoenixResultSet.class).getCurrentRow().getValue(0).getTimestamp() >= clock2.initialTime()
- );
- assertFalse (rs.next());
-
- // Verify the index timestamps via HBase
- PTable pIndexTable = PhoenixRuntime.getTable(conn, indexName);
- Table table = conn.unwrap(PhoenixConnection.class).getQueryServices()
- .getTable(pIndexTable.getPhysicalName().getBytes());
-
- Scan scan = new Scan();
- scan.setTimeRange(clock3.initialTime(), clock3.currentTime());
- ResultScanner scanner = table.getScanner(scan);
- assertTrue(scanner.next() == null);
-
-
- scan = new Scan();
- scan.setTimeRange(clock2.initialTime(), clock3.initialTime());
- scanner = table.getScanner(scan);
- assertTrue(scanner.next() != null);
-
-
- scan = new Scan();
- scan.setTimeRange(clock1.initialTime(), clock2.initialTime());
- scanner = table.getScanner(scan);
- assertTrue(scanner.next() != null);
- conn.close();
- EnvironmentEdgeManager.reset();
}
}
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 dea19ff..1eda539 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
@@ -99,8 +99,12 @@ public class IndexScrutinyWithMaxLookbackIT extends IndexScrutinyToolBaseIT {
@Test
public void testScrutinyOnRowsBeyondMaxLookBack() throws Exception {
setupTables();
- upsertDataAndScrutinize(dataTableName, dataTableFullName, testClock);
- assertBeyondMaxLookbackOutput(dataTableFullName, indexTableFullName);
+ try {
+ upsertDataAndScrutinize(dataTableName, dataTableFullName, testClock);
+ assertBeyondMaxLookbackOutput(dataTableFullName, indexTableFullName);
+ } finally {
+ EnvironmentEdgeManager.reset();
+ }
}
@@ -156,8 +160,12 @@ public class IndexScrutinyWithMaxLookbackIT extends IndexScrutinyToolBaseIT {
@Test
public void testScrutinyOnDeletedRowsBeyondMaxLookBack() throws Exception {
setupTables();
- upsertDataThenDeleteAndScrutinize(dataTableName, dataTableFullName, testClock);
- assertBeyondMaxLookbackOutput(dataTableFullName, indexTableFullName);
+ try {
+ upsertDataThenDeleteAndScrutinize(dataTableName, dataTableFullName, testClock);
+ assertBeyondMaxLookbackOutput(dataTableFullName, indexTableFullName);
+ } finally {
+ EnvironmentEdgeManager.reset();
+ }
}
private void setupTables() throws SQLException {
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 d188fe3..993a2a4 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
@@ -91,8 +91,9 @@ public class IndexToolTimeRangeIT extends BaseUniqueNamesOwnClusterIT {
ps.execute();
conn.commit();
}
+ } finally {
+ EnvironmentEdgeManager.reset();
}
- EnvironmentEdgeManager.injectEdge(null);
}
private static void setupMiniCluster() throws Exception {
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 477f74f..a045161 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
@@ -110,6 +110,8 @@ public class IndexVerificationOldDesignIT extends BaseUniqueNamesOwnClusterIT {
assertEquals(0, indexTool.getJob().getCounters().findCounter(BEFORE_REBUILD_VALID_INDEX_ROW_COUNT).getValue());
assertEquals(0, indexTool.getJob().getCounters().findCounter(BEFORE_REBUILD_MISSING_INDEX_ROW_COUNT).getValue());
assertEquals(0, indexTool.getJob().getCounters().findCounter(BEFORE_REBUILD_EXPIRED_INDEX_ROW_COUNT).getValue());
+ } finally {
+ EnvironmentEdgeManager.reset();
}
}
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 15396cd..010b4f9 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
@@ -40,6 +40,7 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.AfterClass;
import java.io.IOException;
import java.sql.Connection;
@@ -87,6 +88,11 @@ public class MaxLookbackIT extends BaseUniqueNamesOwnClusterIT {
EnvironmentEdgeManager.injectEdge(injectEdge);
}
+ @AfterClass
+ public static synchronized void afterClass() {
+ EnvironmentEdgeManager.reset();
+ }
+
@Test
public void testTooLowSCNWithMaxLookbackAge() throws Exception {
String dataTableName = generateUniqueName();
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NonParameterizedIndexScrutinyToolIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NonParameterizedIndexScrutinyToolIT.java
index 2c99062..938c4f3 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/NonParameterizedIndexScrutinyToolIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/NonParameterizedIndexScrutinyToolIT.java
@@ -178,6 +178,8 @@ public class NonParameterizedIndexScrutinyToolIT extends IndexScrutinyToolBaseIT
assertEquals(2, getCounterValue(counters, EXPIRED_ROW_COUNT));
assertEquals(0, getCounterValue(counters, VALID_ROW_COUNT));
assertEquals(0, getCounterValue(counters, INVALID_ROW_COUNT));
+ } finally {
+ EnvironmentEdgeManager.injectEdge(null);
}
}
@@ -220,6 +222,8 @@ public class NonParameterizedIndexScrutinyToolIT extends IndexScrutinyToolBaseIT
assertEquals(2, getCounterValue(counters, EXPIRED_ROW_COUNT));
assertEquals(0, getCounterValue(counters, VALID_ROW_COUNT));
assertEquals(0, getCounterValue(counters, INVALID_ROW_COUNT));
+ } finally {
+ EnvironmentEdgeManager.injectEdge(null);
}
}
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexVerificationOutputRepositoryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexVerificationOutputRepositoryIT.java
index 3df0318..f24f49d 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexVerificationOutputRepositoryIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexVerificationOutputRepositoryIT.java
@@ -137,6 +137,8 @@ public class IndexVerificationOutputRepositoryIT extends ParallelStatsDisabledIT
int count = TestUtil.getRowCount(hTable, false);
Assert.assertEquals(0, count);
+ } finally {
+ EnvironmentEdgeManager.reset();
}
}
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexVerificationResultRepositoryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexVerificationResultRepositoryIT.java
index 43e5ace..98fe4a0 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexVerificationResultRepositoryIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexVerificationResultRepositoryIT.java
@@ -94,6 +94,8 @@ public class IndexVerificationResultRepositoryIT extends ParallelStatsDisabledIT
int count = TestUtil.getRowCount(hTable, false);
Assert.assertEquals(0, count);
+ } finally {
+ EnvironmentEdgeManager.reset();
}
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/EnvironmentEdgeManager.java b/phoenix-core/src/main/java/org/apache/phoenix/util/EnvironmentEdgeManager.java
index 775dd8c..c5e1a63 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/EnvironmentEdgeManager.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/EnvironmentEdgeManager.java
@@ -52,6 +52,9 @@ public class EnvironmentEdgeManager {
* Injects the given edge such that it becomes the managed entity. If null is
* passed to this method, the default type is assigned to the delegate.
*
+ * <b>Note: This is JVM global. Make sure to call reset() after the test.</b>
+ * See org.apache.hadoop.hbase.util.EnvironmentEdgeManager for other caveats
+ *
* @param edge the new edge.
*/
public static void injectEdge(EnvironmentEdge edge) {
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/index/VerifySingleIndexRowTest.java b/phoenix-core/src/test/java/org/apache/phoenix/index/VerifySingleIndexRowTest.java
index 673ec29..1b8ed55 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/index/VerifySingleIndexRowTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/index/VerifySingleIndexRowTest.java
@@ -349,14 +349,18 @@ public class VerifySingleIndexRowTest extends BaseConnectionlessQueryTest {
public void testVerifySingleIndexRow_expiredIndexRowCount_nonZero() throws IOException {
IndexToolVerificationResult.PhaseResult
expectedPR = new IndexToolVerificationResult.PhaseResult(0, 1, 0, 0, 0, 0,0,0);
- for (Map.Entry<byte[], List<Mutation>>
- entry : indexKeyToMutationMap.entrySet()) {
- initializeLocalMockitoSetup(entry, TestType.EXPIRED);
- expireThisRow();
- //test code
- rebuildScanner.verifySingleIndexRow(indexRow, indexKeyToMutationMap, mostRecentIndexRowKeys, actualPR, true);
-
- assertTrue(actualPR.equals(expectedPR));
+ try {
+ for (Map.Entry<byte[], List<Mutation>>
+ entry : indexKeyToMutationMap.entrySet()) {
+ initializeLocalMockitoSetup(entry, TestType.EXPIRED);
+ expireThisRow();
+ //test code
+ rebuildScanner.verifySingleIndexRow(indexRow, indexKeyToMutationMap, mostRecentIndexRowKeys, actualPR, true);
+
+ assertTrue(actualPR.equals(expectedPR));
+ }
+ } finally {
+ EnvironmentEdgeManager.reset();
}
}
diff --git a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/workload/MultiThreadedRunnerTest.java b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/workload/MultiThreadedRunnerTest.java
index 592aceb..66f65b3 100644
--- a/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/workload/MultiThreadedRunnerTest.java
+++ b/phoenix-pherf/src/test/java/org/apache/phoenix/pherf/workload/MultiThreadedRunnerTest.java
@@ -93,10 +93,14 @@ public class MultiThreadedRunnerTest {
DefaultEnvironmentEdge myClock = Mockito.mock(DefaultEnvironmentEdge.class);
Mockito.when(myClock.currentTime()).thenReturn(0L, 5000L);
EnvironmentEdgeManager.injectEdge(myClock);
- Mockito.when(mockRS.next()).thenReturn(true);
- Mockito.when(mockRS.getLong(1)).thenReturn(1L);
- Pair<Long, Long> results = mtr.getResults(mockRS, "test_iteration", false,0L);
- assertTrue(results.getSecond()>mockQuery.getTimeoutDuration());
+ try {
+ Mockito.when(mockRS.next()).thenReturn(true);
+ Mockito.when(mockRS.getLong(1)).thenReturn(1L);
+ Pair<Long, Long> results = mtr.getResults(mockRS, "test_iteration", false, 0L);
+ assertTrue(results.getSecond() > mockQuery.getTimeoutDuration());
+ } finally {
+ EnvironmentEdgeManager.reset();
+ }
}
@Test
@@ -104,17 +108,21 @@ public class MultiThreadedRunnerTest {
DefaultEnvironmentEdge myClock = Mockito.mock(DefaultEnvironmentEdge.class);
Mockito.when(myClock.currentTime()).thenReturn(0L);
EnvironmentEdgeManager.injectEdge(myClock);
- Mockito.when(mockQuery.getTimeoutDuration()).thenReturn(1000L);
- Mockito.when(mockQuery.getExpectedAggregateRowCount()).thenReturn(1L);
- MultiThreadedRunner mtr = new MultiThreadedRunner("test",
- mockQuery, mockDMR, mockTT,
- 10L, 1000L,
- true, mockRA,
- mockScenario, mockWE, mockParser);
- Mockito.when(mockRS.next()).thenReturn(true, false);
- Mockito.when(mockRS.getLong(1)).thenReturn(1L);
- Pair<Long, Long> results = mtr.getResults(mockRS, "test_iteration", false, 0L);
- assertFalse(results.getSecond() > mockQuery.getTimeoutDuration());
+ try {
+ Mockito.when(mockQuery.getTimeoutDuration()).thenReturn(1000L);
+ Mockito.when(mockQuery.getExpectedAggregateRowCount()).thenReturn(1L);
+ MultiThreadedRunner mtr = new MultiThreadedRunner("test",
+ mockQuery, mockDMR, mockTT,
+ 10L, 1000L,
+ true, mockRA,
+ mockScenario, mockWE, mockParser);
+ Mockito.when(mockRS.next()).thenReturn(true, false);
+ Mockito.when(mockRS.getLong(1)).thenReturn(1L);
+ Pair<Long, Long> results = mtr.getResults(mockRS, "test_iteration", false, 0L);
+ assertFalse(results.getSecond() > mockQuery.getTimeoutDuration());
+ } finally {
+ EnvironmentEdgeManager.reset();
+ }
}
}