Skip to content

fix(server-nestjs): make the gitlab mirror rotation test deterministic - #2707

Open
shikanime wants to merge 1 commit into
mainfrom
fix/flaky-mirror-rotation-test
Open

fix(server-nestjs): make the gitlab mirror rotation test deterministic#2707
shikanime wants to merge 1 commit into
mainfrom
fix/flaky-mirror-rotation-test

Conversation

@shikanime

Copy link
Copy Markdown
Member

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 threshold est 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, revokeProjectToken reç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-nestjs verte (661 passed, 69 skipped) ; eslint vert sur le fichier.

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 <[email protected]>
Signed-off-by: William Phetsinorath <[email protected]>
Change-Id: I00684d9367006f164ab2d86d642544336a6a6964
@github-actions github-actions Bot added the built label Sep 9, 2026
@shikanime
shikanime marked this pull request as ready for review September 9, 2026 12:49
@shikanime
shikanime requested a review from a team as a code owner September 9, 2026 12:49
@shikanime shikanime self-assigned this Sep 9, 2026
@shikanime shikanime added the bug Something isn't working label Sep 9, 2026
@shikanime shikanime added this to the 9.26.0 milestone Sep 9, 2026
@cloud-pi-native-sonarqube

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working built

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant