This is an automated email from the ASF dual-hosted git repository.
kturner pushed a commit to branch 2.1
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/2.1 by this push:
new f2448f28da tests TabletMetadata error when prev row not seen (#4678)
f2448f28da is described below
commit f2448f28da970d94acff3e59867bd36a2c1fb305
Author: Keith Turner <[email protected]>
AuthorDate: Fri Jun 14 17:26:17 2024 -0400
tests TabletMetadata error when prev row not seen (#4678)
---
.../core/metadata/schema/TabletMetadataTest.java | 27 ++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git
a/core/src/test/java/org/apache/accumulo/core/metadata/schema/TabletMetadataTest.java
b/core/src/test/java/org/apache/accumulo/core/metadata/schema/TabletMetadataTest.java
index 7d9284ba00..a164efc8ed 100644
---
a/core/src/test/java/org/apache/accumulo/core/metadata/schema/TabletMetadataTest.java
+++
b/core/src/test/java/org/apache/accumulo/core/metadata/schema/TabletMetadataTest.java
@@ -24,6 +24,7 @@ import static
org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSec
import static
org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN;
import static
org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.ServerColumnFamily.FLUSH_COLUMN;
import static
org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.ServerColumnFamily.TIME_COLUMN;
+import static
org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType.DIR;
import static
org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType.LAST;
import static
org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType.LOCATION;
import static
org.apache.accumulo.core.metadata.schema.TabletMetadata.ColumnType.PREV_ROW;
@@ -288,6 +289,32 @@ public class TabletMetadataTest {
assertTrue(closeCalled.get());
}
+ @Test
+ public void testAbsentPrevRow() {
+ // If the prev row is fetched, then it is expected to be seen. Ensure that
if it was not seen
+ // that TabletMetadata fails when attempting to use it. Want to ensure
null is not returned for
+ // this case.
+ Mutation mutation =
+ new Mutation(MetadataSchema.TabletsSection.encodeRow(TableId.of("5"),
new Text("df")));
+ DIRECTORY_COLUMN.put(mutation, new Value("d1"));
+ SortedMap<Key,Value> rowMap = toRowMap(mutation);
+
+ var tm = TabletMetadata.convertRow(rowMap.entrySet().iterator(),
+ EnumSet.allOf(ColumnType.class), false);
+
+ var msg = assertThrows(IllegalStateException.class,
tm::getExtent).getMessage();
+ assertTrue(msg.contains("No prev endrow seen"));
+ msg = assertThrows(IllegalStateException.class,
tm::getPrevEndRow).getMessage();
+ assertTrue(msg.contains("No prev endrow seen"));
+
+ // should see a slightly different error message when the prev row is not
fetched
+ tm = TabletMetadata.convertRow(rowMap.entrySet().iterator(),
EnumSet.of(DIR), false);
+ msg = assertThrows(IllegalStateException.class,
tm::getExtent).getMessage();
+ assertTrue(msg.contains("PREV_ROW was not fetched"));
+ msg = assertThrows(IllegalStateException.class,
tm::getPrevEndRow).getMessage();
+ assertTrue(msg.contains("PREV_ROW was not fetched"));
+ }
+
private SortedMap<Key,Value> toRowMap(Mutation mutation) {
SortedMap<Key,Value> rowMap = new TreeMap<>();
mutation.getUpdates().forEach(cu -> {