This is an automated email from the ASF dual-hosted git repository. domgarguilo pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/main by this push: new 2cfc633 Fix faulty test: `SortedLogRecoveryTest.testMissingDefinition` (#2494) 2cfc633 is described below commit 2cfc63396b3879c2c4b3ed773c1aad366745402d Author: Dom G <dominic.gargu...@gmail.com> AuthorDate: Tue Feb 15 09:36:26 2022 -0500 Fix faulty test: `SortedLogRecoveryTest.testMissingDefinition` (#2494) * Fix faulty test * Include IDE suggested improvements --- .../tserver/log/SortedLogRecoveryTest.java | 24 +++++++++------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/server/tserver/src/test/java/org/apache/accumulo/tserver/log/SortedLogRecoveryTest.java b/server/tserver/src/test/java/org/apache/accumulo/tserver/log/SortedLogRecoveryTest.java index ef2c878..0cd265d 100644 --- a/server/tserver/src/test/java/org/apache/accumulo/tserver/log/SortedLogRecoveryTest.java +++ b/server/tserver/src/test/java/org/apache/accumulo/tserver/log/SortedLogRecoveryTest.java @@ -30,7 +30,6 @@ import static org.easymock.EasyMock.verify; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import java.io.File; import java.io.IOException; @@ -113,8 +112,7 @@ public class SortedLogRecoveryTest { @Override public boolean equals(Object obj) { - return this == obj - || (obj != null && obj instanceof KeyValue && 0 == compareTo((KeyValue) obj)); + return this == obj || (obj instanceof KeyValue && 0 == compareTo((KeyValue) obj)); } @Override @@ -142,7 +140,7 @@ public class SortedLogRecoveryTest { result.key.tablet = (KeyExtent) fileExtentMutation; break; case MUTATION: - result.value.mutations = Arrays.asList((Mutation) fileExtentMutation); + result.value.mutations = List.of((Mutation) fileExtentMutation); break; case MANY_MUTATIONS: result.value.mutations = Arrays.asList((Mutation[]) fileExtentMutation); @@ -346,16 +344,15 @@ public class SortedLogRecoveryTest { } @Test - public void testMissingDefinition() { + public void testMissingDefinition() throws IOException { // Create a test log KeyValue[] entries = {createKeyValue(OPEN, 0, -1, "1"),}; Map<String,KeyValue[]> logs = new TreeMap<>(); logs.put("testlog", entries); // Recover - try { - recover(logs, extent); - fail("tablet should not have been found"); - } catch (Throwable t) {} + List<Mutation> mutations = recover(logs, extent); + // Verify recovered data + assertEquals(0, mutations.size()); } @Test @@ -820,8 +817,7 @@ public class SortedLogRecoveryTest { Map<String,KeyValue[]> logs = new TreeMap<>(); logs.put("entries", entries); - HashSet<String> filesSet = new HashSet<>(); - filesSet.addAll(Arrays.asList(tabletFiles)); + HashSet<String> filesSet = new HashSet<>(Arrays.asList(tabletFiles)); List<Mutation> mutations = recover(logs, filesSet, extent, bufferSize); if (startMatches) { @@ -892,7 +888,7 @@ public class SortedLogRecoveryTest { } @Test - public void testConsecutiveCompactionFinishEvents() throws IOException { + public void testConsecutiveCompactionFinishEvents() { Mutation m1 = new ServerMutation(new Text("r1")); m1.put("f1", "q1", "v1"); @@ -1048,7 +1044,7 @@ public class SortedLogRecoveryTest { } @Test - public void testFileWithoutOpen() throws IOException { + public void testFileWithoutOpen() { Mutation m1 = new ServerMutation(new Text("r1")); m1.put("f1", "q1", "v1"); @@ -1144,7 +1140,6 @@ public class SortedLogRecoveryTest { * Pulled from BCFile.Reader() */ private final Utils.Version API_VERSION_3 = new Utils.Version((short) 3, (short) 0); - private final String defaultPrefix = "data:"; private Compression.Algorithm getCompressionFromRFile(FSDataInputStream fsin, long fileLength) throws IOException { @@ -1166,6 +1161,7 @@ public class SortedLogRecoveryTest { assertTrue(count > 0); String fullMetaName = Utils.readString(in); + String defaultPrefix = "data:"; if (fullMetaName != null && !fullMetaName.startsWith(defaultPrefix)) { throw new IOException("Corrupted Meta region Index"); }