ctubbsii commented on code in PR #5929:
URL: https://github.com/apache/accumulo/pull/5929#discussion_r2376811591


##########
test/src/main/java/org/apache/accumulo/test/functional/OnDemandTabletUnloadingIT.java:
##########
@@ -169,6 +171,54 @@ public void testTabletUnloader() throws Exception {
     }
   }
 
+  /**
+   * Test the behavior of transitioning tablets from having a tablet 
availability of HOSTED to
+   * ONDEMAND. This transition should cause all tablets to unload because 
tablets are hosted but do
+   * not have a hosting requested column set.
+   */
+  @Test
+  public void testTransitionFromHostedToOndemand() throws Exception {
+    try (AccumuloClient c = 
Accumulo.newClient().from(getClientProps()).build()) {
+
+      String tableName = super.getUniqueNames(1)[0];
+
+      TreeSet<Text> splits = new TreeSet<>();
+      splits.add(new Text("f"));
+      splits.add(new Text("m"));
+      splits.add(new Text("t"));
+
+      NewTableConfiguration ntc = new NewTableConfiguration();
+      ntc.withSplits(splits);

Review Comment:
   This can be made more succinct
   
   ```suggestion
         var splits = new TreeSet<>(Set.of(new Text("f"), new Text("m"), new 
Text("t")));
         var ntc = new NewTableConfiguration().withSplits(splits);
   ```
   
   Also, I noticed that withSplits requires a sorted set. It really shouldn't. 
Returning a sorted set in an API makes sense, but requiring as input is too 
restrictive. It can sort internally, if needed. Of course, this wouldn't matter 
if Java had a `SortedSet.of()` immutable type.



##########
test/src/main/java/org/apache/accumulo/test/functional/OnDemandTabletUnloadingIT.java:
##########
@@ -169,6 +171,54 @@ public void testTabletUnloader() throws Exception {
     }
   }
 
+  /**
+   * Test the behavior of transitioning tablets from having a tablet 
availability of HOSTED to
+   * ONDEMAND. This transition should cause all tablets to unload because 
tablets are hosted but do
+   * not have a hosting requested column set.
+   */
+  @Test
+  public void testTransitionFromHostedToOndemand() throws Exception {
+    try (AccumuloClient c = 
Accumulo.newClient().from(getClientProps()).build()) {
+
+      String tableName = super.getUniqueNames(1)[0];
+
+      TreeSet<Text> splits = new TreeSet<>();
+      splits.add(new Text("f"));
+      splits.add(new Text("m"));
+      splits.add(new Text("t"));
+
+      NewTableConfiguration ntc = new NewTableConfiguration();
+      ntc.withSplits(splits);
+      // set this really high because the manager should unassign tablets 
because of a lack of a
+      // hosting requested column
+      ntc.setProperties(
+          Map.of(LastAccessTimeOnDemandTabletUnloader.INACTIVITY_THRESHOLD, 
"1000000"));
+      ntc.withInitialTabletAvailability(TabletAvailability.HOSTED);
+      c.tableOperations().create(tableName, ntc);
+      String tableId = c.tableOperations().tableIdMap().get(tableName);
+
+      // wait for all tablets in table to be hosted
+      Wait.waitFor(() -> ManagerAssignmentIT.countTabletsWithLocation(c, 
TableId.of(tableId)) == 4);
+
+      // transition all tablets to ondemand. Since no tablets have a hosting 
requested column set
+      // the manager should unassign all tablets.
+      c.tableOperations().setTabletAvailability(tableName, new Range(),
+          TabletAvailability.ONDEMAND);
+
+      Wait.waitFor(() -> ManagerAssignmentIT.countTabletsWithLocation(c, 
TableId.of(tableId)) == 0);
+
+      // scan tablet.
+      try (var scanner = c.createScanner(tableName)) {
+        scanner.setRange(new Range("h"));
+        assertFalse(scanner.iterator().hasNext());
+      }
+
+      // ensure only one tablet is hosted now since we transitioned all 
tablets to ONDEMAND
+      Wait.waitFor(() -> ManagerAssignmentIT.countTabletsWithLocation(c, 
TableId.of(tableId)) == 1);
+      Wait.waitFor(() -> ONDEMAND_ONLINE_COUNT == 1);

Review Comment:
   There's a lot of waiting without timeouts. Does this test have a global 
timeout that is tunable with the timeout.factor?



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to