From 47eac5221bd59ce0228f8e01825b35f8be7bf0c7 Mon Sep 17 00:00:00 2001 From: Manu Zhang Date: Tue, 29 Oct 2024 03:57:39 +0800 Subject: [PATCH] Spark: Flaky test due temp directory (#10811) --- .../iceberg/spark/source/TestDataFrameWrites.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/source/TestDataFrameWrites.java b/spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/source/TestDataFrameWrites.java index bf49bfba550f..01c36b824ea6 100644 --- a/spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/source/TestDataFrameWrites.java +++ b/spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/source/TestDataFrameWrites.java @@ -28,6 +28,7 @@ import java.io.File; import java.io.IOException; import java.net.URI; +import java.nio.file.NoSuchFileException; import java.util.Arrays; import java.util.Collection; import java.util.Iterator; @@ -35,6 +36,7 @@ import java.util.Map; import java.util.Random; import org.apache.avro.generic.GenericData.Record; +import org.apache.commons.io.FileUtils; import org.apache.hadoop.conf.Configuration; import org.apache.iceberg.Files; import org.apache.iceberg.Parameter; @@ -419,5 +421,13 @@ public void testFaultToleranceOnWrite() throws IOException { assertThat(snapshotBeforeFailingWrite).isEqualTo(snapshotAfterFailingWrite); assertThat(resultBeforeFailingWrite).isEqualTo(resultAfterFailingWrite); + + while (location.exists()) { + try { + FileUtils.deleteDirectory(location); + } catch (NoSuchFileException e) { + // ignore NoSuchFileException when a file is already deleted + } + } } }