You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by gu...@apache.org on 2025/08/22 06:53:38 UTC
(spark) branch master updated: [SPARK-53345][SS][TESTS] Use withTempDir for consistent directory across restarts in streaming test
This is an automated email from the ASF dual-hosted git repository.
gurwls223 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 7007e1c7ad64 [SPARK-53345][SS][TESTS] Use withTempDir for consistent directory across restarts in streaming test
7007e1c7ad64 is described below
commit 7007e1c7ad646bfdc2a89579b2abaa2b3facc6af
Author: Dylan Wong <dy...@databricks.com>
AuthorDate: Fri Aug 22 15:53:25 2025 +0900
[SPARK-53345][SS][TESTS] Use withTempDir for consistent directory across restarts in streaming test
### What changes were proposed in this pull request?
Use withTempDir for consistent directory across restarts in test.
### Why are the changes needed?
Test was flaky due to using an unpredictable temp directory for a streaming query that tests against restarts. This test was introduced in SPARK-53069.
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
Test only change.
### Was this patch authored or co-authored using generative AI tooling?
No
Closes #52088 from dylanwong250/SPARK-53345.
Authored-by: Dylan Wong <dy...@databricks.com>
Signed-off-by: Hyukjin Kwon <gu...@apache.org>
---
.../streaming/TransformWithListStateTTLSuite.scala | 63 ++++++++++++----------
1 file changed, 34 insertions(+), 29 deletions(-)
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/streaming/TransformWithListStateTTLSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/streaming/TransformWithListStateTTLSuite.scala
index 15312883d4d6..d2036a32f1d1 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/streaming/TransformWithListStateTTLSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/streaming/TransformWithListStateTTLSuite.scala
@@ -750,42 +750,47 @@ class TransformWithListStateTTLSuite extends TransformWithStateTTLTest
withSQLConf(SQLConf.STATE_STORE_PROVIDER_CLASS.key ->
classOf[RocksDBStateStoreProvider].getName,
SQLConf.SHUFFLE_PARTITIONS.key -> "1") {
- val ttlConfig = TTLConfig(ttlDuration = Duration.ofMinutes(10))
- val inputStream = MemoryStream[String]
- val result = inputStream.toDS()
- .groupByKey(x => x)
- .transformWithState(
- new MultiStatefulVariableTTLProcessor(ttlConfig),
- TimeMode.ProcessingTime(),
- OutputMode.Append())
- val clock = new StreamManualClock
+ withTempDir { checkpointLocation =>
+ val ttlConfig = TTLConfig(ttlDuration = Duration.ofMinutes(10))
+ val inputStream = MemoryStream[String]
+ val result = inputStream.toDS()
+ .groupByKey(x => x)
+ .transformWithState(
+ new MultiStatefulVariableTTLProcessor(ttlConfig),
+ TimeMode.ProcessingTime(),
+ OutputMode.Append())
+ val clock = new StreamManualClock
- testStream(result)(
- StartStream(Trigger.ProcessingTime("1 second"), triggerClock = clock),
+ testStream(result)(
+ StartStream(Trigger.ProcessingTime("1 second"), triggerClock = clock,
+ checkpointLocation = checkpointLocation.getAbsolutePath),
- AddData(inputStream, "k1"),
- AdvanceManualClock(1 * 1000),
- CheckNewAnswer(("k1", 1)),
- assertNumStateRows(total = 3, updated = 3),
+ AddData(inputStream, "k1"),
+ AdvanceManualClock(1 * 1000),
+ CheckNewAnswer(("k1", 1)),
+ assertNumStateRows(total = 3, updated = 3),
- StopStream,
- StartStream(Trigger.ProcessingTime("1 second"), triggerClock = clock),
+ StopStream,
+ StartStream(Trigger.ProcessingTime("1 second"), triggerClock = clock,
+ checkpointLocation = checkpointLocation.getAbsolutePath),
- AddData(inputStream, "k1"),
- AdvanceManualClock(1 * 1000),
- CheckNewAnswer(("k1", 2)),
- assertNumStateRows(total = 4, updated = 3),
+ AddData(inputStream, "k1"),
+ AdvanceManualClock(1 * 1000),
+ CheckNewAnswer(("k1", 2)),
+ assertNumStateRows(total = 4, updated = 3),
- StopStream,
- StartStream(Trigger.ProcessingTime("1 second"), triggerClock = clock),
+ StopStream,
+ StartStream(Trigger.ProcessingTime("1 second"), triggerClock = clock,
+ checkpointLocation = checkpointLocation.getAbsolutePath),
- AddData(inputStream, "k1"),
- AdvanceManualClock(1 * 1000),
- CheckNewAnswer(("k1", 3)),
- assertNumStateRows(total = 5, updated = 3),
+ AddData(inputStream, "k1"),
+ AdvanceManualClock(1 * 1000),
+ CheckNewAnswer(("k1", 3)),
+ assertNumStateRows(total = 5, updated = 3),
- StopStream
- )
+ StopStream
+ )
+ }
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org