This is an automated email from the ASF dual-hosted git repository.

dlmarion 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 9bfa684f9e Refactored TimeoutIT to be a SimpleSuite test (#6418)
9bfa684f9e is described below

commit 9bfa684f9e8bf45defd15ef3a76d6ea23d204c25
Author: Dave Marion <[email protected]>
AuthorDate: Tue Jun 9 15:10:32 2026 -0400

    Refactored TimeoutIT to be a SimpleSuite test (#6418)
    
    Modified TimeoutIT to break the tests into separate
    methods so that each test had its own timeout. The
    three tests in a single method were taking just over
    the timeout value.
---
 .../apache/accumulo/test/functional/TimeoutIT.java | 138 ------------------
 .../test/functional/TimeoutIT_SimpleSuite.java     | 155 +++++++++++++++++++++
 2 files changed, 155 insertions(+), 138 deletions(-)

diff --git 
a/test/src/main/java/org/apache/accumulo/test/functional/TimeoutIT.java 
b/test/src/main/java/org/apache/accumulo/test/functional/TimeoutIT.java
deleted file mode 100644
index 53b5607bb4..0000000000
--- a/test/src/main/java/org/apache/accumulo/test/functional/TimeoutIT.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.accumulo.test.functional;
-
-import static java.util.concurrent.TimeUnit.SECONDS;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-import java.time.Duration;
-import java.util.Collections;
-
-import org.apache.accumulo.core.client.Accumulo;
-import org.apache.accumulo.core.client.AccumuloClient;
-import org.apache.accumulo.core.client.BatchScanner;
-import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
-import org.apache.accumulo.core.client.IteratorSetting;
-import org.apache.accumulo.core.client.MutationsRejectedException;
-import org.apache.accumulo.core.client.Scanner;
-import org.apache.accumulo.core.client.TimedOutException;
-import org.apache.accumulo.core.clientImpl.ThriftScanner;
-import org.apache.accumulo.core.data.Mutation;
-import org.apache.accumulo.core.data.Range;
-import org.apache.accumulo.harness.AccumuloClusterHarness;
-import org.junit.jupiter.api.Test;
-
-public class TimeoutIT extends AccumuloClusterHarness {
-
-  @Override
-  protected Duration defaultTimeout() {
-    return Duration.ofSeconds(75);
-  }
-
-  @Test
-  public void run() throws Exception {
-    try (AccumuloClient client = 
Accumulo.newClient().from(getClientProps()).build()) {
-      String[] tableNames = getUniqueNames(3);
-      testBatchWriterTimeout(client, tableNames[0]);
-      testBatchScannerTimeout(client, tableNames[1]);
-      testScannerTimeout(client, tableNames[2]);
-    }
-  }
-
-  public void testBatchWriterTimeout(AccumuloClient client, String tableName) 
throws Exception {
-    client.tableOperations().create(tableName);
-    client.tableOperations().addConstraint(tableName, 
SlowConstraint.class.getName());
-
-    // give constraint time to propagate through zookeeper
-    Thread.sleep(SECONDS.toMillis(1));
-
-    BatchWriter bw =
-        client.createBatchWriter(tableName, new 
BatchWriterConfig().setTimeout(3, SECONDS));
-
-    Mutation mut = new Mutation("r1");
-    mut.put("cf1", "cq1", "v1");
-
-    bw.addMutation(mut);
-    var mre =
-        assertThrows(MutationsRejectedException.class, bw::close, "batch 
writer did not timeout");
-    if (mre.getCause() instanceof TimedOutException) {
-      return;
-    }
-    throw mre;
-  }
-
-  public void testBatchScannerTimeout(AccumuloClient client, String tableName) 
throws Exception {
-    client.tableOperations().create(tableName);
-
-    try (BatchWriter bw = client.createBatchWriter(tableName)) {
-      Mutation m = new Mutation("r1");
-      m.put("cf1", "cq1", "v1");
-      m.put("cf1", "cq2", "v2");
-      m.put("cf1", "cq3", "v3");
-      m.put("cf1", "cq4", "v4");
-      bw.addMutation(m);
-    }
-
-    try (BatchScanner bs = client.createBatchScanner(tableName)) {
-      bs.setRanges(Collections.singletonList(new Range()));
-
-      // should not timeout
-      bs.setTimeout(5, SECONDS);
-      bs.forEach((k, v) -> {});
-
-      IteratorSetting iterSetting = new IteratorSetting(100, 
SlowIterator.class);
-      iterSetting.addOption("sleepTime", 2000 + "");
-      bs.addScanIterator(iterSetting);
-
-      assertThrows(TimedOutException.class, () -> bs.iterator().next(),
-          "batch scanner did not time out");
-    }
-  }
-
-  public void testScannerTimeout(AccumuloClient client, String tableName) 
throws Exception {
-    client.tableOperations().create(tableName);
-
-    try (BatchWriter bw = client.createBatchWriter(tableName)) {
-      Mutation m = new Mutation("r1");
-      m.put("cf1", "cq1", "v1");
-      m.put("cf1", "cq2", "v2");
-      m.put("cf1", "cq3", "v3");
-      m.put("cf1", "cq4", "v4");
-      bw.addMutation(m);
-    }
-
-    try (Scanner scanner = client.createScanner(tableName)) {
-      scanner.setRange(new Range());
-
-      // should not timeout
-      scanner.setTimeout(5, SECONDS);
-      scanner.forEach((k, v) -> {});
-
-      IteratorSetting iterSetting = new IteratorSetting(100, 
SlowIterator.class);
-      iterSetting.addOption("sleepTime", 6000 + "");
-      scanner.addScanIterator(iterSetting);
-
-      var exception = assertThrows(RuntimeException.class, () -> 
scanner.iterator().next(),
-          "scanner did not time out");
-      assertEquals(ThriftScanner.ScanTimedOutException.class, 
exception.getCause().getClass());
-    }
-  }
-}
diff --git 
a/test/src/main/java/org/apache/accumulo/test/functional/TimeoutIT_SimpleSuite.java
 
b/test/src/main/java/org/apache/accumulo/test/functional/TimeoutIT_SimpleSuite.java
new file mode 100644
index 0000000000..be8a3b9cf9
--- /dev/null
+++ 
b/test/src/main/java/org/apache/accumulo/test/functional/TimeoutIT_SimpleSuite.java
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.accumulo.test.functional;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import java.time.Duration;
+import java.util.Collections;
+
+import org.apache.accumulo.core.client.Accumulo;
+import org.apache.accumulo.core.client.AccumuloClient;
+import org.apache.accumulo.core.client.BatchScanner;
+import org.apache.accumulo.core.client.BatchWriter;
+import org.apache.accumulo.core.client.BatchWriterConfig;
+import org.apache.accumulo.core.client.IteratorSetting;
+import org.apache.accumulo.core.client.MutationsRejectedException;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.client.TimedOutException;
+import org.apache.accumulo.core.clientImpl.ThriftScanner;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Range;
+import org.apache.accumulo.harness.SharedMiniClusterBase;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+public class TimeoutIT_SimpleSuite extends SharedMiniClusterBase {
+
+  @Override
+  protected Duration defaultTimeout() {
+    return Duration.ofSeconds(75);
+  }
+
+  @BeforeAll
+  public static void setup() throws Exception {
+    SharedMiniClusterBase.startMiniCluster();
+  }
+
+  @AfterAll
+  public static void tearDown() throws Exception {
+    SharedMiniClusterBase.stopMiniCluster();
+  }
+
+  @Test
+  public void testBatchWriterTimeout() throws Exception {
+    try (AccumuloClient client = 
Accumulo.newClient().from(getClientProps()).build()) {
+      String[] tableNames = getUniqueNames(1);
+      String tableName = tableNames[0];
+      client.tableOperations().create(tableName);
+      client.tableOperations().addConstraint(tableName, 
SlowConstraint.class.getName());
+
+      // give constraint time to propagate through zookeeper
+      Thread.sleep(SECONDS.toMillis(1));
+
+      BatchWriter bw =
+          client.createBatchWriter(tableName, new 
BatchWriterConfig().setTimeout(3, SECONDS));
+
+      Mutation mut = new Mutation("r1");
+      mut.put("cf1", "cq1", "v1");
+
+      bw.addMutation(mut);
+      var mre =
+          assertThrows(MutationsRejectedException.class, bw::close, "batch 
writer did not timeout");
+      if (mre.getCause() instanceof TimedOutException) {
+        return;
+      }
+      throw mre;
+    }
+  }
+
+  @Test
+  public void testBatchScannerTimeout() throws Exception {
+    try (AccumuloClient client = 
Accumulo.newClient().from(getClientProps()).build()) {
+      String[] tableNames = getUniqueNames(1);
+      String tableName = tableNames[0];
+      client.tableOperations().create(tableName);
+
+      try (BatchWriter bw = client.createBatchWriter(tableName)) {
+        Mutation m = new Mutation("r1");
+        m.put("cf1", "cq1", "v1");
+        m.put("cf1", "cq2", "v2");
+        m.put("cf1", "cq3", "v3");
+        m.put("cf1", "cq4", "v4");
+        bw.addMutation(m);
+      }
+
+      try (BatchScanner bs = client.createBatchScanner(tableName)) {
+        bs.setRanges(Collections.singletonList(new Range()));
+
+        // should not timeout
+        bs.setTimeout(5, SECONDS);
+        bs.forEach((k, v) -> {});
+
+        IteratorSetting iterSetting = new IteratorSetting(100, 
SlowIterator.class);
+        iterSetting.addOption("sleepTime", 2000 + "");
+        bs.addScanIterator(iterSetting);
+
+        assertThrows(TimedOutException.class, () -> bs.iterator().next(),
+            "batch scanner did not time out");
+      }
+    }
+  }
+
+  @Test
+  public void testScannerTimeout() throws Exception {
+    try (AccumuloClient client = 
Accumulo.newClient().from(getClientProps()).build()) {
+      String[] tableNames = getUniqueNames(1);
+      String tableName = tableNames[0];
+      client.tableOperations().create(tableName);
+
+      try (BatchWriter bw = client.createBatchWriter(tableName)) {
+        Mutation m = new Mutation("r1");
+        m.put("cf1", "cq1", "v1");
+        m.put("cf1", "cq2", "v2");
+        m.put("cf1", "cq3", "v3");
+        m.put("cf1", "cq4", "v4");
+        bw.addMutation(m);
+      }
+
+      try (Scanner scanner = client.createScanner(tableName)) {
+        scanner.setRange(new Range());
+
+        // should not timeout
+        scanner.setTimeout(5, SECONDS);
+        scanner.forEach((k, v) -> {});
+
+        IteratorSetting iterSetting = new IteratorSetting(100, 
SlowIterator.class);
+        iterSetting.addOption("sleepTime", 6000 + "");
+        scanner.addScanIterator(iterSetting);
+
+        var exception = assertThrows(RuntimeException.class, () -> 
scanner.iterator().next(),
+            "scanner did not time out");
+        assertEquals(ThriftScanner.ScanTimedOutException.class, 
exception.getCause().getClass());
+      }
+    }
+  }
+}

Reply via email to