Problem/Motivation

Drupal\Tests\purge_users\Kernel\UserIdsTest::testUserIdsByUserValues with data set all_purge_conditions.notify is flaky on 4.x: on some runs the query returns extra users whose login (or created, for never-logged-in users) sits exactly on the 1-year boundary, e.g. created1y_loginNever, created2y_login1y, created3y_login1y.

The failing dataset configures all four purge conditions at 30 months and a pre-notification lead of 18 months, so the notify threshold is 30 − 18 = 12 months. Test users are seeded with strtotime('-1 year'), which sits exactly on that 12-month threshold. Small wall-clock drift between the seed and the subsequent query flips the strict < comparison and leaks those users into the notification set.

Example failed job (before retry): job #9457996 on MR !60 pipeline 800958. Retried jobs #9458699 and #9458700 passed without code changes, which confirms the flake is timing-dependent rather than functional.

5.x's equivalent dataset already uses user_before_notification_value = 12 (introduced as part of the policy refactor in #3427680), which moves the threshold to 30 − 12 = 18 months — safely between the seeded 1-year and 2-year marks. The 4.x mixed dataset was already adjusted in #3411228 (commit 7525178), but all_purge_conditions was missed.

Steps to reproduce

Run UserIdsTest::testUserIdsByUserValues repeatedly on 4.x. The failure rate depends on wall-clock drift between seeding and querying; on GitLab CI it reproduces often enough to block pipelines on unrelated MRs.

Proposed resolution

In tests/src/Kernel/UserIdsTest.php, change user_before_notification_value from 18 to 12 in the all_purge_conditions dataset. This shifts the notify threshold to 18 months — midway between the seeded 1-year and 2-year marks, so the < comparison is no longer at a boundary.

The expected notify list remains unchanged: all six users currently listed (created3y_login2y*, created2y_loginNever*, created2y_login2y*) have their time component at 2 years, well above the new 18-month threshold, so the array_diff against the purge candidates yields the same result.

Remaining tasks

  • Apply the one-line change in the dataset.
  • Verify the pipeline stays green across current, previous major, and next minor matrices.

Release notes snippet

Fixes a flaky kernel test on the 4.x branch caused by the pre-notification threshold sitting exactly on the 1-year boundary used by seeded test fixtures.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mably created an issue. See original summary.

mably’s picture

Issue summary: View changes

  • mably committed be809d62 on 4.x
    fix: #3586114 UserIdsTest flaky on 4.x: pre-notification threshold sits...
mably’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.