Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#55919 closed defect (bug) (fixed)

Composer: Disable process timeout for PHPUnit tests

Reported by: sergeybiryukov's profile SergeyBiryukov Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 6.1 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch has-testing-info
Focuses: Cc:

Description

When running npm run grunt phpunit:multisite locally, I get an error around 80%:

The following exception is caused by a process timeout
Check https://getcomposer.org/doc/06-config.md#process-timeout for details

In Process.php line 1204:

  The process "'/usr/bin/php7.4' -d allow_url_fopen='1' -d disable_functions='' -d memory_limit='-1' ./vendor/phpunit
  /phpunit/phpunit '--verbose' '-c' 'tests/phpunit/multisite.xml'" exceeded the timeout of 300 seconds.


test [--dev] [--no-dev] [--] [<args>...]

Warning:  Use --force to continue.

Aborted due to warnings.
npm ERR! code ELIFECYCLE
npm ERR! errno 3
npm ERR! WordPress@6.1.0 grunt: `grunt "phpunit:multisite"`
npm ERR! Exit status 3
npm ERR!
npm ERR! Failed at the WordPress@6.1.0 grunt script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

This appears to be caused by Composer's default timeout of 300 seconds. Disabling the timeout as suggested in the documentation resolves the issue for me.

Attachments (1)

55919.diff (545 bytes) - added by SergeyBiryukov 2 years ago.

Download all attachments as: .zip

Change History (7)

@SergeyBiryukov
2 years ago

#1 @SergeyBiryukov
2 years ago

  • Keywords has-patch added

#2 @robinwpdeveloper
2 years ago

Much needed. Thanks @SergeyBiryukov

#3 @ironprogrammer
2 years ago

  • Keywords has-testing-info added

Reproduction Report

I am able to force the reported error by setting Composer's process-timeout value to less than the time expected to run the multisite unit test suite (in my case, this takes ~2.5 minutes).

Environment

  • Hardware: MacBook Pro Apple M1 Pro
  • OS: macOS 12.6
  • Server: nginx/1.23.1
  • PHP: 7.4.30
  • WordPress: 6.1-alpha-53344-src

Pre-Test Configuration

  1. Set Composer's process-timeout to a low value (e.g. 10 seconds) to simulate an insufficient timeout period: export COMPOSER_PROCESS_TIMEOUT=10.
  2. Confirm the process-timeout value with: composer config process-timeout.

Actual Results

  • ✅ Error occurs after ~10 seconds (per process-timeout override above):
    The following exception is caused by a process timeout
    Check https://getcomposer.org/doc/06-config.md#process-timeout for details
    
    In Process.php line 1204:
                                                                                                       
      The process "'/opt/homebrew/Cellar/php@7.4/7.4.30_1/bin/php' -d allow_url_fopen='1' -d disable_  
      functions='' -d memory_limit='1536M' ./vendor/phpunit/phpunit/phpunit '--verbose' '-c' 'tests/p  
      hpunit/multisite.xml'" exceeded the timeout of 10 seconds.                                       
                                                                                                       
    
    test [--dev] [--no-dev] [--] [<args>...]
    
    Warning:  Use --force to continue.
    
    Aborted due to warnings.
    npm ERR! code ELIFECYCLE
    npm ERR! errno 3
    npm ERR! WordPress@6.1.0 grunt: `grunt "phpunit:multisite"`
    npm ERR! Exit status 3
    npm ERR! 
    npm ERR! Failed at the WordPress@6.1.0 grunt script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     /<redacted>/.npm/_logs/2022-09-21T05_06_59_646Z-debug.log
    

Additional Notes

  • Bypassing Composer and running phpunit --verbose -c tests/phpunit/multisite.xml directly will not reproduce the issue.
Last edited 2 years ago by ironprogrammer (previous) (diff)

#4 @ironprogrammer
2 years ago

Test Report

LGTM 👍🏻 As indicated above, this can be tested by forcing an insufficient time period to complete the test suite.

Patch tested: https://core.trac.wordpress.org/attachment/ticket/55919/55919.diff

Environment

  • Hardware: MacBook Pro Apple M1 Pro
  • OS: macOS 12.6
  • Server: nginx/1.23.1
  • PHP: 7.4.30
  • WordPress: 6.1-alpha-53344-src

Pre-Test Configuration

  1. Set Composer's process-timeout to a low value (e.g. 10 seconds) to simulate an insufficient timeout period: export COMPOSER_PROCESS_TIMEOUT=10.
  2. Confirm the process-timeout value with: composer config process-timeout.

Actual Results

  • ✅ Patch update overrides process-timeout value and tests complete without error.

This ticket was mentioned in Slack in #core by robinwpdeveloper. View the logs.


2 years ago

#6 @SergeyBiryukov
2 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 54355:

Build/Test Tools: Disable process timeout when running PHPUnit tests via Composer.

When running the full test suite locally via npm run grunt phpunit or composer test, it is not uncommon for the test run to exceed the Composer's default timeout, causing an error in the middle of the test output:

The process "..." exceeded the timeout of 300 seconds.

This commit disables the process timeout for the composer test command, allowing the test run to complete successfully.

Follow-up to [47881], [51016].

Props ironprogrammer, robinwpdeveloper, SergeyBiryukov.
Fixes #55919.

Note: See TracTickets for help on using tickets.