fix(server-nestjs): make the gitlab mirror rotation test deterministic - #2707
Open
shikanime wants to merge 1 commit into
Open
fix(server-nestjs): make the gitlab mirror rotation test deterministic#2707shikanime wants to merge 1 commit into
shikanime wants to merge 1 commit into
Conversation
The rotation test seeded the vault secret with faker.date.past({ years: 2 }), a uniform draw over [0; 730] days. With the default 250-day rotation threshold, roughly one draw in three lands inside the threshold window: the rotation branch never fires, revokeProjectToken ends up with zero calls and the assertion fails. This is the intermittent unit-tests job failure seen on recent PRs.
Draw the secret age with faker.date.birthdate({ min: 1, max: 2, mode: 'age' }): the value stays fully randomized and relative to now, but the draw always lands one to two years in the past, safely beyond the rotation threshold, so the rotation branch is exercised deterministically.
Refs #2706
Co-authored-by: Automata <automata@shikanime.studio>
Signed-off-by: William Phetsinorath <william.phetsinorath-open@interieur.gouv.fr>
Change-Id: I00684d9367006f164ab2d86d642544336a6a6964
|
shikanime
enabled auto-merge
September 9, 2026 13:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

0 New Issues
0 Fixed Issues
0 Accepted Issues
No data about coverage (24.10% Estimated after merge)
Issues liées
#2706 (fermer délibérément après la fusion)
Quel est le comportement actuel ?
Le test
gitlabService > handleUpsert > proactively rotates the mirror token when the vault secret is older than the rotation thresholdest instable :faker.date.past({ years: 2 })tire uniformément dans [0 ; 730] jours et, avec le seuil de rotation par défaut de 250 jours, environ un tirage sur trois tombe sous le seuil. La branche de rotation ne se déclenche pas,revokeProjectTokenreçoit zéro appel et l'assertion échoue — d'où les échecs intermittents du job unit-tests observés sur plusieurs PR.Quel est le nouveau comportement ?
L'âge du secret est tiré avec
faker.date.birthdate({ min: 1, max: 2, mode: 'age' }): la valeur reste entièrement aléatoire et relative à maintenant, mais le tirage tombe toujours entre un et deux ans dans le passé, au-delà du seuil de rotation — la branche de rotation s'exécute de manière déterministe.Cette PR introduit-elle un breaking change ?
Non.
Autres informations
Validation : 9 exécutions consécutives du spec (24 tests) passent sur les variantes successives du correctif ; suite complète
apps/server-nestjsverte (661 passed, 69 skipped) ; eslint vert sur le fichier.