gjacoby126 commented on a change in pull request #751: PHOENIX-5735 Add the
maxLookBack logic in the inline validation.
URL: https://github.com/apache/phoenix/pull/751#discussion_r402654931
##########
File path:
phoenix-core/src/test/java/org/apache/phoenix/index/VerifySingleIndexRowTest.java
##########
@@ -428,33 +426,136 @@ public void
testVerifySingleIndexRow_expectedMutations_null() throws IOException
rebuildScanner.verifySingleIndexRow(indexRow, actualPR);
}
+
+ // Test the major compaction on index table only.
+ // There is at least one expected mutation within maxLookBack that has its
matching one in the actual list.
+ // However there are some expected mutations outside of maxLookBack, which
matching ones in actual list may be compacted away.
+ // We will report such row as a valid row.
@Test
- public void testVerifySingleIndexRow_actualMutations_null() throws
IOException {
- byte [] validRowKey = getValidRowKey();
- when(indexRow.getRow()).thenReturn(validRowKey);
-
when(rebuildScanner.prepareActualIndexMutations(indexRow)).thenReturn(null);
- exceptionRule.expect(DoNotRetryIOException.class);
-
exceptionRule.expectMessage(IndexRebuildRegionScanner.ACTUAL_MUTATION_IS_NULL_OR_EMPTY);
- rebuildScanner.verifySingleIndexRow(indexRow, actualPR);
+ public void
testVerifySingleIndexRow_compactionOnIndexTable_atLeastOneExpectedMutationWithinMaxLookBack()
throws Exception {
+ String dataRowKey = "k1";
+ byte[] indexRowKey1Bytes = generateIndexRowKey(dataRowKey, "val1");
+ ManualEnvironmentEdge injectEdge = new ManualEnvironmentEdge();
+ injectEdge.setValue(1);
+ EnvironmentEdgeManager.injectEdge(injectEdge);
+
+ List<Mutation> expectedMutations = new ArrayList<>();
+ List<Mutation> actualMutations = new ArrayList<>();
+ // change the maxLookBack from infinite to some interval, which allows
to simulate the mutation beyond the maxLookBack window.
+ long maxLookbackInMills = 10 * 1000;
+ rebuildScanner.setMaxLookBackInMills(maxLookbackInMills);
+
+ Put put = new Put(indexRowKey1Bytes);
+ Cell cell = CellUtil.createCell(indexRowKey1Bytes,
+
QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES,
+ QueryConstants.EMPTY_COLUMN_BYTES,
+
EnvironmentEdgeManager.currentTimeMillis(),
+ KeyValue.Type.Put.getCode(),
+ IndexRegionObserver.VERIFIED_BYTES);
+ put.add(cell);
+ // This mutation is beyond maxLookBack, so add it to expectedMutations
only.
+ expectedMutations.add(put);
+
+ // advance the time of maxLookBack, so last mutation will be outside
of maxLookBack,
+ // next mutation will be within maxLookBack
+ injectEdge.incrementValue(maxLookbackInMills);
+ put = new Put(indexRowKey1Bytes);
+ cell = CellUtil.createCell(indexRowKey1Bytes,
+ QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES,
+ QueryConstants.EMPTY_COLUMN_BYTES,
+ EnvironmentEdgeManager.currentTimeMillis(),
+ KeyValue.Type.Put.getCode(),
+ IndexRegionObserver.VERIFIED_BYTES);
+ put.add(cell);
+ // This mutation is in both expectedMutations and actualMutations, as
it is within the maxLookBack, so it will not get chance to be compacted away
+ expectedMutations.add(put);
+ actualMutations.add(put);
+ Result actualMutationsScanResult = Result.create(Arrays.asList(cell));
+
+ Map<byte[], List<Mutation>> indexKeyToMutationMap =
Maps.newTreeMap((Bytes.BYTES_COMPARATOR));
+ indexKeyToMutationMap.put(indexRowKey1Bytes, expectedMutations);
+ rebuildScanner.setIndexKeyToMutationMap(indexKeyToMutationMap);
+
when(rebuildScanner.prepareActualIndexMutations(any(Result.class))).thenReturn(actualMutations);
+
+ injectEdge.incrementValue(1);
+ IndexToolVerificationResult.PhaseResult actualPR = new
IndexToolVerificationResult.PhaseResult();
+ // Report this validation as a success
+
assertTrue(rebuildScanner.verifySingleIndexRow(actualMutationsScanResult,
actualPR));
+ // validIndexRowCount = 1
+ IndexToolVerificationResult.PhaseResult expectedPR = new
IndexToolVerificationResult.PhaseResult(1, 0, 0, 0, 0, 0);
+ assertTrue(actualPR.equals(expectedPR));
}
+ // Test the major compaction on index table only.
+ // All expected mutations are beyond the maxLookBack, and there is no
matching ones in actual list for any of them because of major compaction
Review comment:
nit: "there are no matching ones in the actual list"
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services