Skip to content

Conversation

@amartinezfayo
Copy link
Member

@amartinezfayo amartinezfayo commented Jan 2, 2026

Fixed flaky test TestTLSConfig/update_key_file_with_an_invalid_key_start_error_log_loop that was failing due to race conditions in log validation.

Example of failure run: https://github.com/spiffe/spire/actions/runs/20639598110/job/59269434940#step:5:417

The original test used require.Eventually with a condition that could pass prematurely (with 0 logs) before any errors were actually logged, and accumulated logs from previous subtests caused incorrect counts.
The fix removes the unnecessary Eventually wrapper (since the mock clock makes logging synchronous), adds logHook.Reset() calls to isolate each test's log entries, and replaces the condition with a single-line range assertion.
Also, introduced constants (testFileSyncInterval, testTickerIterations, testTotalSyncDuration) to replace magic numbers throughout the test, making the timing relationships explicit.

…t_error_log_loop

Signed-off-by: Agustín Martínez Fayó <amartinezfayo@gmail.com>
@sorindumitru sorindumitru merged commit f88ee8c into spiffe:main Jan 3, 2026
49 checks passed
@amartinezfayo amartinezfayo added this to the 1.14.1 milestone Jan 3, 2026
amartinezfayo added a commit to amartinezfayo/spire that referenced this pull request Jan 5, 2026
…or_log_loop in diskcertmanager package.

The previous fix in spiffe#6528 removed Eventually assuming synchronous execution with the mock clock, but the goroutine processing ticker events needs real wall-clock time to write log entries after clk.Add() returns, causing intermittent failures when assertions ran before logs appeared.

Signed-off-by: Agustín Martínez Fayó <amartinezfayo@gmail.com>
amartinezfayo added a commit that referenced this pull request Jan 5, 2026
…or_log_loop in diskcertmanager package. (#6533)

The previous fix in #6528 removed Eventually assuming synchronous execution with the mock clock, but the goroutine processing ticker events needs real wall-clock time to write log entries after clk.Add() returns, causing intermittent failures when assertions ran before logs appeared.

Signed-off-by: Agustín Martínez Fayó <amartinezfayo@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants