dongjoon-hyun opened a new pull request, #595:
URL: https://github.com/apache/spark-connect-swift/pull/595

   ### What changes were proposed in this pull request?
   
   This PR aims to fix the flaky `StreamingQueryTests.status` test by calling 
`query.processAllAvailable()` before `query.stop()`. This makes the test wait 
until the query has finished initializing.
   
   ### Why are the changes needed?
   
   `StreamingQueryTests.status` fails intermittently in CI. For example:
   - 
https://github.com/apache/spark-connect-swift/actions/runs/38934002527/job/117084779028
   
   ```
   ✘ Test status() recorded an issue at StreamingQueryTests.swift:128:5: 
Expectation failed: stoppedStatus.statusMessage == "Stopped"
   ↳ stoppedStatus.statusMessage == "Stopped" → false
   ↳   stoppedStatus.statusMessage → "Initializing sources"
   ```
   
   The test calls `stop()` right after starting the query, which races with 
server-side initialization. In `StreamExecution.runStream()`, the server first 
sets the status message to `Initializing sources`. It then tries 
`state.compareAndSet(INITIALIZING, ACTIVE)`. If `stop()` has already been 
called, this transition fails and the server leaves the cleanup to the 
`finally` block without setting the status message to `Stopped`. As a result, 
the message stays as `Initializing sources`.
   
   The server's `processAllAvailable()` returns only after the query has become 
`ACTIVE` and processed the available data. So stopping the query after it 
always reaches the code path that sets `Stopped`.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. This is a test-only change.
   
   ### How was this patch tested?
   
   Pass the CIs.
   
   I also ran the test 10 times in a row against a local Apache Spark 4.1.3 
Connect server, and all runs passed.
   
   ```
   swift test --no-parallel --filter "StreamingQueryTests/status"
   ```
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Opus 5.5


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to