This is an automated email from the ASF dual-hosted git repository.

gjacoby pushed a commit to branch 4.x-HBase-1.3
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/4.x-HBase-1.3 by this push:
     new caf013c  PHOENIX-5677 - Replace System.currentTimeMillis with 
EnvironmentEdgeManager in non-test code (Addendum to fix IndexScrutinyIT)
caf013c is described below

commit caf013ceee5fcd64b1c8e49d71c781b6a6df1eb0
Author: Geoffrey Jacoby <[email protected]>
AuthorDate: Wed Jan 22 13:33:48 2020 -0800

    PHOENIX-5677 - Replace System.currentTimeMillis with EnvironmentEdgeManager 
in non-test code (Addendum to fix IndexScrutinyIT)
---
 .../end2end/index/PartialIndexRebuilderIT.java     | 69 ++--------------------
 .../index/IndexScrutinyMapperForTest.java          |  4 +-
 2 files changed, 8 insertions(+), 65 deletions(-)

diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PartialIndexRebuilderIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PartialIndexRebuilderIT.java
index cbbdfec..4565caa 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PartialIndexRebuilderIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/PartialIndexRebuilderIT.java
@@ -65,20 +65,17 @@ import org.apache.phoenix.util.IndexUtil;
 import org.apache.phoenix.util.MetaDataUtil;
 import org.apache.phoenix.util.ReadOnlyProps;
 import org.apache.phoenix.util.Repeat;
-import org.apache.phoenix.util.RunUntilFailure;
 import org.apache.phoenix.util.SchemaUtil;
 import org.apache.phoenix.util.TestUtil;
+import org.junit.After;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Test;
-import org.junit.runner.RunWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.collect.Maps;
 
 @SuppressWarnings("deprecation")
-@RunWith(RunUntilFailure.class)
 public class PartialIndexRebuilderIT extends BaseUniqueNamesOwnClusterIT {
     private static final Logger LOGGER = 
LoggerFactory.getLogger(PartialIndexRebuilderIT.class);
     private static final Random RAND = new Random(5);
@@ -112,6 +109,11 @@ public class PartialIndexRebuilderIT extends 
BaseUniqueNamesOwnClusterIT {
             indexRebuildTaskRegionEnvironment.getConfiguration());
     }
 
+    @After
+    public void cleanup(){
+        EnvironmentEdgeManager.reset();
+    }
+
     private static void runIndexRebuilder(String table) throws 
InterruptedException, SQLException {
         runIndexRebuilder(Collections.<String>singletonList(table));
     }
@@ -1073,65 +1075,6 @@ public class PartialIndexRebuilderIT extends 
BaseUniqueNamesOwnClusterIT {
         }
     }
 
-    @Test
-    @Repeat(5)
-    public void testIndexActiveIfRegionMovesWhileRebuilding() throws Throwable 
{
-        final MyClock clock = new MyClock(1000);
-        EnvironmentEdgeManager.injectEdge(clock);
-        String schemaName = generateUniqueName();
-        String tableName = generateUniqueName();
-        String indexName = generateUniqueName();
-        int nThreads = 5;
-        int nRows = 50;
-        int nIndexValues = 23;
-        int batchSize = 200;
-        final CountDownLatch doneSignal = new CountDownLatch(nThreads);
-        boolean[] cancel = new boolean[1];
-
-        final String fullTableName = SchemaUtil.getTableName(schemaName, 
tableName);
-        final String fullIndexName = SchemaUtil.getTableName(schemaName, 
indexName);
-        try (Connection conn = DriverManager.getConnection(getUrl())) {
-            try {
-                conn.createStatement().execute("CREATE TABLE " + fullTableName
-                    + "(k1 INTEGER NOT NULL, k2 INTEGER NOT NULL, v1 INTEGER, "
-                    + "CONSTRAINT pk PRIMARY KEY (k1,k2)) STORE_NULLS=true, 
VERSIONS=1");
-                conn.createStatement().execute("CREATE INDEX " + indexName + " 
ON "
-                    + fullTableName + "(v1)");
-                conn.commit();
-                long disableTS = clock.currentTime();
-                HTableInterface metaTable = 
conn.unwrap(PhoenixConnection.class).getQueryServices()
-                        
.getTable(PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME_BYTES);
-                IndexUtil.updateIndexState(fullIndexName, disableTS,
-                    metaTable, PIndexState.DISABLE);
-                assertTrue(TestUtil.checkIndexState(conn, fullIndexName,
-                    PIndexState.DISABLE, disableTS));
-                mutateRandomly(fullTableName, nThreads, nRows,
-                    nIndexValues, batchSize, doneSignal);
-                assertTrue("Ran out of time", doneSignal.await(120, 
TimeUnit.SECONDS));
-                runIndexRebuilder(fullTableName);
-                assertTrue(TestUtil.checkIndexState(conn, fullIndexName,
-                    PIndexState.INACTIVE, disableTS));
-                clock.time += WAIT_AFTER_DISABLED;
-                runIndexRebuilderAsync(500,cancel,fullTableName);
-                unassignRegionAsync(fullIndexName);
-                while (runRebuildOnce) {
-                    PIndexState indexState = TestUtil.getIndexState(conn, 
fullIndexName);
-                    if (indexState != PIndexState.INACTIVE && indexState != 
PIndexState.ACTIVE) {
-                        cancel[0] = true;
-                        throw new Exception("Index State should not transtion 
from INACTIVE to "
-                            + indexState);
-                    }
-                }
-                assertTrue(TestUtil.checkIndexState(conn, fullIndexName, 
PIndexState.ACTIVE, 0L));
-            } finally {
-                cancel[0] = true;
-                EnvironmentEdgeManager.injectEdge(null);
-            }
-            long totalRows = IndexScrutiny.scrutinizeIndex(conn, 
fullTableName, fullIndexName);
-            assertEquals(nRows, totalRows);
-        }
-    }
-
     public static class WriteFailingRegionObserver extends 
SimpleRegionObserver {
         @Override
         public void 
postBatchMutate(ObserverContext<RegionCoprocessorEnvironment> c, 
MiniBatchOperationInProgress<Mutation> miniBatchOp) throws IOException {
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexScrutinyMapperForTest.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexScrutinyMapperForTest.java
index d2a0f35..99d50ee 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexScrutinyMapperForTest.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexScrutinyMapperForTest.java
@@ -28,13 +28,13 @@ public class IndexScrutinyMapperForTest extends 
IndexScrutinyMapper {
         long delta;
 
         public ScrutinyTestClock(long delta) {
-            initialTime = EnvironmentEdgeManager.currentTimeMillis() + delta;
+            initialTime = System.currentTimeMillis() + delta;
             this.delta = delta;
         }
 
         @Override
         public long currentTime() {
-            return EnvironmentEdgeManager.currentTimeMillis() + delta;
+            return System.currentTimeMillis() + delta;
         }
     }
 

Reply via email to