Random test fail in NodeRevisionDeleteTest

Created on 6 July 2022, over 2 years ago
Updated 7 March 2024, 9 months ago

Problem/Motivation

NodeRevisionDeleteTest::testGetRelativeTim has a race condition: https://www.drupal.org/pift-ci-job/2420740 . It's calling strtotime() in the provider (which is executed during test discovery) and the implementation and expect it to return the same. If too much time passes between defining the test and running it (for example when running all tests at once because the functional test then runs first), you get a different result. It's probably less likely to happen on CI as it runs tests one-by one, but it's still possible to have a second-switch in the middle of discovering/running the test as that example shows.

Steps to reproduce

Proposed resolution

There is no simple fix for this, the only idea I have is passing the current request time from the time service. Then you can mock that and set the same fixed or current request time as an extra test method argument and use the same for the provider and implementation.

FWIW, the whole test is testing fairly little, especially the provider variations. Mostly this is testing strtotime(), it doesn't matter which argumenst are passed in, your code always does exactly the same. So it would also be an option to drop the provider completely. You could also remove the provider, but would still need to set the baseline so that you have a predictable result. within the test module, it's less likely to have a second-switch, but still possible

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

🇨🇭Switzerland berdir Switzerland

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024