You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by ad...@apache.org on 2026/09/19 18:13:44 UTC
(ozone) branch master updated: HDDS-16482. Fix flaky TestBlockDataStreamOutput.closeAfterWriteFailureThrows (#11263)
This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new cc125926f88 HDDS-16482. Fix flaky TestBlockDataStreamOutput.closeAfterWriteFailureThrows (#11263)
cc125926f88 is described below
commit cc125926f88ca997566e16c22b971dc934790895
Author: Andy Huang <16...@users.noreply.github.com>
AuthorDate: Sun Sep 20 02:13:37 2026 +0800
HDDS-16482. Fix flaky TestBlockDataStreamOutput.closeAfterWriteFailureThrows (#11263)
---
.../scm/storage/TestBlockDataStreamOutput.java | 25 +++++-----------------
1 file changed, 5 insertions(+), 20 deletions(-)
diff --git a/hadoop-hdds/client/src/test/java/org/apache/hadoop/hdds/scm/storage/TestBlockDataStreamOutput.java b/hadoop-hdds/client/src/test/java/org/apache/hadoop/hdds/scm/storage/TestBlockDataStreamOutput.java
index c66d7006c37..35aaac2a5af 100644
--- a/hadoop-hdds/client/src/test/java/org/apache/hadoop/hdds/scm/storage/TestBlockDataStreamOutput.java
+++ b/hadoop-hdds/client/src/test/java/org/apache/hadoop/hdds/scm/storage/TestBlockDataStreamOutput.java
@@ -27,7 +27,6 @@
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.CompletionException;
import org.apache.commons.lang3.RandomUtils;
import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos;
import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.Type;
@@ -201,26 +200,12 @@ void closeAfterWriteFailureThrows() throws Exception {
stream.write(ByteBuffer.wrap(data), 0, data.length); // ok, stays in buffer
byte[] data2 = randomBytes(CHUNK_SIZE + 50);
- // This write will fill the buffer and trigger a chunk write that may fail.
- // Close will surface the exception, which will be caused by the injected exception,
- // however based on thread scheduling, the actual exception we get back from the stream
- // is either a CompletionException caused by the injected exception or the
- // injected exception itself so check for both.
stream.write(ByteBuffer.wrap(data2), 0, data2.length);
- Throwable e = assertThrows(IOException.class, () -> stream.close());
- if (e instanceof CompletionException) {
- assertThat(e.getMessage()).contains("Failed to write chunk ");
- boolean foundExpectedCause = false;
- while (e.getCause() != null) {
- e = e.getCause();
- if (e instanceof IOException && e.getMessage().contains("chunk write failed due to injected failure")) {
- foundExpectedCause = true;
- }
- }
- assertTrue(foundExpectedCause);
- } else {
- assertThat(e.getMessage()).contains("chunk write failed due to injected failure");
- }
+ // The exception wrapping depends on thread scheduling, so verify the root cause.
+ IOException e = assertThrows(IOException.class, stream::close);
+ assertThat(e)
+ .hasRootCauseInstanceOf(IOException.class)
+ .hasRootCauseMessage("chunk write failed due to injected failure");
}
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ozone.apache.org
For additional commands, e-mail: commits-help@ozone.apache.org