This is an automated email from the ASF dual-hosted git repository. kturner pushed a commit to branch elasticity in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/elasticity by this push: new 649d881dec adds auto split test to ComprehensiveIT (#4711) 649d881dec is described below commit 649d881dec7a9a9158094b11a6efe6077810ff98 Author: Keith Turner <ktur...@apache.org> AuthorDate: Thu Jun 27 07:55:55 2024 -0700 adds auto split test to ComprehensiveIT (#4711) ComprehensiveIT was covering all fate table op steps except for the one related to automatic splits. This commit adds a test to ComprehensiveIT that exercise autosplits. This covers that fate step that is only run for automatic splits. Automatic splits are an important feature of Accumulo, so in general its good to cover them in ComprehensiveIT. --- .../apache/accumulo/test/ComprehensiveBaseIT.java | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/test/src/main/java/org/apache/accumulo/test/ComprehensiveBaseIT.java b/test/src/main/java/org/apache/accumulo/test/ComprehensiveBaseIT.java index b204474fc8..71c42c43fc 100644 --- a/test/src/main/java/org/apache/accumulo/test/ComprehensiveBaseIT.java +++ b/test/src/main/java/org/apache/accumulo/test/ComprehensiveBaseIT.java @@ -20,6 +20,7 @@ package org.apache.accumulo.test; import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.stream.Collectors.toMap; +import static org.apache.accumulo.core.util.LazySingletons.RANDOM; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; @@ -33,6 +34,7 @@ import java.util.AbstractMap; import java.util.ArrayList; import java.util.Collection; import java.util.EnumSet; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -43,6 +45,7 @@ import java.util.TreeSet; import java.util.UUID; import java.util.function.Consumer; import java.util.function.Predicate; +import java.util.stream.Collectors; import java.util.stream.Stream; import org.apache.accumulo.core.client.Accumulo; @@ -163,6 +166,47 @@ public abstract class ComprehensiveBaseIT extends SharedMiniClusterBase { } } + @Test + public void testAutoSplit() throws Exception { + String table = getUniqueNames(1)[0]; + try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) { + var newTableConfig = + new NewTableConfiguration().setProperties(Map.of(Property.TABLE_SPLIT_THRESHOLD.getKey(), + "4K", Property.TABLE_FILE_COMPRESSED_BLOCK_SIZE.getKey(), "1K")); + client.tableOperations().create(table, newTableConfig); + + var random = RANDOM.get(); + byte[] data = new byte[1024]; + + assertEquals(0, client.tableOperations().listSplits(table).size()); + + Map<String,Text> expectedValues = new HashMap<>(); + + try (var writer = client.createBatchWriter(table)) { + for (int i = 0; i < 100; i++) { + String row = String.format("%016x", random.nextLong()); + Mutation m = new Mutation(row); + random.nextBytes(data); + m.at().family("data").qualifier("random").put(data); + writer.addMutation(m); + expectedValues.put(row, new Text(data)); + } + } + + client.tableOperations().flush(table, null, null, true); + + // ensure table automatically splits + Wait.waitFor(() -> client.tableOperations().listSplits(table).size() > 20); + + try (var scanner = client.createScanner(table)) { + var seenValues = scanner.stream().collect(Collectors + .toMap(e -> e.getKey().getRowData().toString(), e -> new Text(e.getValue().get()))); + assertEquals(expectedValues, seenValues); + } + + } + } + @Test public void testFlushAndIterator() throws Exception { String table = getUniqueNames(1)[0];