mirror of
https://github.com/kata-containers/kata-containers.git
synced 2026-03-18 10:44:10 +00:00
The `test_inner_stream_timeout` test case was prone to failure due to a race condition between the main thread and the background handler. The test relied on hardcoded `thread::sleep` durations, which could cause the second read operation to time out (150ms window) before the main thread performed its write (after a 300ms sleep) under high system load. This commit stabilizes the test by: 1. Replacing fixed sleep durations with a `Condvar` and a `stage` variable to implement a deterministic state machine. 2. Synchronizing the threads so that the main thread only writes data after the background handler has confirmed it is ready or has completed its previous phase. 3. Ensuring the read timeout is explicitly managed between different validation stages to prevent accidental `TimedOut` errors. This change eliminates the flakiness and ensures the test passes consistently across different CIenvironments. Fixes #12618 Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>