spiffe / spire

The SPIFFE Runtime Environment
https://spiffe.io
Apache License 2.0
1.81k stars 478 forks source link

Fix for TestRotator flaky test #5643

Closed amartinezfayo closed 2 days ago

amartinezfayo commented 1 week ago

There is a race condition in the TestRotator test that can make it to fail: https://github.com/spiffe/spire/actions/runs/11742647891/job/32713865973?pr=5642

--- FAIL: TestRotator (60.10s)
    --- FAIL: TestRotator/reattest_expires_after_startup (60.02s)
        rotator_test.go:211: timed out waiting for rotation check to finish
FAIL
FAIL    github.com/spiffe/spire/pkg/agent/svid  60.267s

For the "reattest expires after startup" test case, we advance the clock two minutes. But since the rotator is launched in a separated go routine, that may happen before the rotator is running. Added a hook to make sure that we advance the clock after the rotator is running.