keith-turner commented on code in PR #5929:
URL: https://github.com/apache/accumulo/pull/5929#discussion_r2376839776


##########
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:
   the waitfor methods will use a defualt timeout of 30s when one is not 
specified.



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