Skip to content

test: fix flaky force_renew test (detect renewal by serial)#1269

Merged
buchdag merged 2 commits into
nginx-proxy:mainfrom
JamBalaya56562:fix/force-renew-flaky-test
Jun 18, 2026
Merged

test: fix flaky force_renew test (detect renewal by serial)#1269
buchdag merged 2 commits into
nginx-proxy:mainfrom
JamBalaya56562:fix/force-renew-flaky-test

Conversation

@JamBalaya56562

Copy link
Copy Markdown
Contributor

What

Make the force_renew integration test reliable. It has been failing intermittently in CI (maintainers have had to re-run it to get a green build).

Why

The test forced a renewal and then polled for the certificate's expiration date (notAfter) to increase. That signal is unreliable: test/setup/pebble/pebble-config.json defines several certificate profiles with different validity periods (5y default, 1y, 6-day), and a renewed certificate can be issued under a different profile than the original — giving it an earlier notAfter even though the renewal succeeded. The poll then never sees notAfter increase and the test fails after 30s.

Example from a failed run:

First  certificate expiration epoch : 1939542803   # issued + ~5y  (default profile, 157766400s)
Second certificate expiration epoch : 1813312416   # issued + ~1y  (long-lived profile, 31536000s)

The two issuances were only ~13s apart (so the renewal did happen), but the renewed cert got a shorter validity, so notAfter went backwards.

How

Detect the renewal by the certificate serial number, which changes on every (re-)issuance regardless of profile, validity period or timing:

  • test/tests/test-functions.sh — add a get_cert_serial helper.
  • test/tests/force_renew/run.sh — compare the serial before/after the forced renewal instead of the expiration date, and capture the force_renew output so a genuine failure is diagnosable (it was previously discarded to /dev/null).

Test-only change; no product code is affected.

🤖 Generated with Claude Code

The force_renew test polled for the certificate's expiration date (notAfter) to
increase after a forced renewal. This is unreliable: the Pebble test config
defines several certificate profiles with different validity periods, so a
renewed cert can be issued under a different profile and end up with an EARLIER
expiration than the original even though the renewal succeeded — making the test
fail intermittently (maintainers had to re-run it).

Detect the renewal by the certificate serial number instead, which changes on
every (re-)issuance regardless of profile/validity/timing. Add a get_cert_serial
test helper and capture the force_renew output so a failure is diagnosable.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Comment thread test/tests/test-functions.sh Outdated
Comment thread test/tests/force_renew/run.sh Outdated
@buchdag buchdag changed the title test: fix flaky force_renew test (detect renewal by serial, not expiration) test: fix flaky force_renew test (detect renewal by serial) Jun 18, 2026
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@JamBalaya56562 JamBalaya56562 requested a review from buchdag June 18, 2026 10:35
@buchdag buchdag merged commit 7a59b2e into nginx-proxy:main Jun 18, 2026
45 checks passed
@JamBalaya56562 JamBalaya56562 deleted the fix/force-renew-flaky-test branch June 18, 2026 11:34
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