WordPress / phpunit-test-reporter

GNU General Public License v3.0
29 stars 21 forks source link

'No such file or dir errors' reporting for multiple hosts #83

Closed kittenkamala closed 4 years ago

kittenkamala commented 4 years ago

Test failures are being reported by a few hosts:

https://make.wordpress.org/hosting/test-results/r48410/a2hostinbot-r48410/ https://make.wordpress.org/hosting/test-results/r48410/ionosbot-r48410/ https://make.wordpress.org/hosting/test-results/r48410/sakurabot-r48410/

On the host's end, the output is as follows:

WP_REST_Plugins_Controller_Test::test_create_item
unlink(/var/www/vhosts/wp-test-runner/tests/phpunit/includes/../data/link-manager.zip): No such file or directory
WP_REST_Plugins_Controller_Test::test_create_item_and_activate
unlink(/var/www/vhosts/wp-test-runner/tests/phpunit/includes/../data/link-manager.zip): No such file or directory
WP_REST_Plugins_Controller_Test::test_create_item_and_activate_errors_if_no_permission_to_activate_plugin

This was suggested in the #hosting-community channel

"sstoyanov 6:08 AM Hey, I made some progress with the issue of the failing tests. Here is what I've found: For some reason, the WP_Upgrader->run is called twice for each failing test. The unpack_package is also called twice(because the WP_Upgrader->run method is called twice ). When unpack_package is trying to unlink the file, but it exists only for the first iteration. I've added file_exists check in the method above, and for each test, I got true, followed by false, which means that the method is trying to delete the link-manager.zip twice."

supersoju commented 4 years ago

Additional information from the verbose PHPUnit output :

1) WP_REST_Plugins_Controller_Test::test_create_item
unlink(/var/www/vhosts/wp-test-runner/tests/phpunit/includes/../data/link-manager.zip): No such file or directory

/var/www/vhosts/wp-test-runner/build/wp-admin/includes/class-wp-upgrader.php:329
/var/www/vhosts/wp-test-runner/build/wp-admin/includes/class-wp-upgrader.php:776
/var/www/vhosts/wp-test-runner/build/wp-admin/includes/class-language-pack-upgrader.php:256
/var/www/vhosts/wp-test-runner/build/wp-admin/includes/class-language-pack-upgrader.php:104
/var/www/vhosts/wp-test-runner/build/wp-includes/class-wp-hook.php:289
/var/www/vhosts/wp-test-runner/build/wp-includes/class-wp-hook.php:311
/var/www/vhosts/wp-test-runner/build/wp-includes/plugin.php:478
/var/www/vhosts/wp-test-runner/build/wp-admin/includes/class-wp-upgrader.php:841
/var/www/vhosts/wp-test-runner/build/wp-admin/includes/class-plugin-upgrader.php:108
/var/www/vhosts/wp-test-runner/build/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php:306
/var/www/vhosts/wp-test-runner/build/wp-includes/rest-api/class-wp-rest-server.php:1027
/var/www/vhosts/wp-test-runner/tests/phpunit/includes/spy-rest-server.php:57
/var/www/vhosts/wp-test-runner/build/wp-includes/rest-api.php:447
/var/www/vhosts/wp-test-runner/tests/phpunit/tests/rest-api/rest-plugins-controller.php:379

2) WP_REST_Plugins_Controller_Test::test_create_item_and_activate
unlink(/var/www/vhosts/wp-test-runner/tests/phpunit/includes/../data/link-manager.zip): No such file or directory

/var/www/vhosts/wp-test-runner/build/wp-admin/includes/class-wp-upgrader.php:329
/var/www/vhosts/wp-test-runner/build/wp-admin/includes/class-wp-upgrader.php:776
/var/www/vhosts/wp-test-runner/build/wp-admin/includes/class-language-pack-upgrader.php:256
/var/www/vhosts/wp-test-runner/build/wp-admin/includes/class-language-pack-upgrader.php:104
/var/www/vhosts/wp-test-runner/build/wp-includes/class-wp-hook.php:289
/var/www/vhosts/wp-test-runner/build/wp-includes/class-wp-hook.php:311
/var/www/vhosts/wp-test-runner/build/wp-includes/plugin.php:478
/var/www/vhosts/wp-test-runner/build/wp-admin/includes/class-wp-upgrader.php:841
/var/www/vhosts/wp-test-runner/build/wp-admin/includes/class-plugin-upgrader.php:108
/var/www/vhosts/wp-test-runner/build/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php:306
/var/www/vhosts/wp-test-runner/build/wp-includes/rest-api/class-wp-rest-server.php:1027
/var/www/vhosts/wp-test-runner/tests/phpunit/includes/spy-rest-server.php:57
/var/www/vhosts/wp-test-runner/build/wp-includes/rest-api.php:447
/var/www/vhosts/wp-test-runner/tests/phpunit/tests/rest-api/rest-plugins-controller.php:404

3) WP_REST_Plugins_Controller_Test::test_create_item_and_activate_errors_if_no_permission_to_activate_plugin
unlink(/var/www/vhosts/wp-test-runner/tests/phpunit/includes/../data/link-manager.zip): No such file or directory

/var/www/vhosts/wp-test-runner/build/wp-admin/includes/class-wp-upgrader.php:329
/var/www/vhosts/wp-test-runner/build/wp-admin/includes/class-wp-upgrader.php:776
/var/www/vhosts/wp-test-runner/build/wp-admin/includes/class-language-pack-upgrader.php:256
/var/www/vhosts/wp-test-runner/build/wp-admin/includes/class-language-pack-upgrader.php:104
/var/www/vhosts/wp-test-runner/build/wp-includes/class-wp-hook.php:289
/var/www/vhosts/wp-test-runner/build/wp-includes/class-wp-hook.php:311
/var/www/vhosts/wp-test-runner/build/wp-includes/plugin.php:478
/var/www/vhosts/wp-test-runner/build/wp-admin/includes/class-wp-upgrader.php:841
/var/www/vhosts/wp-test-runner/build/wp-admin/includes/class-plugin-upgrader.php:108
/var/www/vhosts/wp-test-runner/build/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php:306
/var/www/vhosts/wp-test-runner/build/wp-includes/rest-api/class-wp-rest-server.php:1027
/var/www/vhosts/wp-test-runner/tests/phpunit/includes/spy-rest-server.php:57
/var/www/vhosts/wp-test-runner/build/wp-includes/rest-api.php:447
/var/www/vhosts/wp-test-runner/tests/phpunit/tests/rest-api/rest-plugins-controller.php:431
TimothyBJacobs commented 4 years ago

That stack trace was helpful. I think the error is happening because after the install completes, the language pack upgrader is firing. I'm guess on some hosts, the test environment might have plugins that have pending language updates?

What eventually happens is the upgrader_pre_download filter get's called for the plugin upgrader, but also for the language pack upgrader.

This will require a fix in the Core tests to make the package overwriting more narrow. Though we'll probably also want to unhook the async language updater as well so we aren't needlessly querying that API.

pfefferle commented 4 years ago

@TimothyBJacobs I also see these issues, but the installation will be cleaned up after every run, so there shouldn't be version updates.

TimothyBJacobs commented 4 years ago

@pfefferle what happens if you dump wp_get_translation_updates before and after the create item test?

pfefferle commented 4 years ago

@TimothyBJacobs Oh, I have not thought about translations... good point! Will check this tomorrow... thanks for the hint!

getsource commented 4 years ago

Is there already a ticket in core trac about this?

If not, I think it might be a good idea to make one and move this conversation over there for visibility.

TimothyBJacobs commented 4 years ago

No, not yet. I meant to create one. I've done that now, https://core.trac.wordpress.org/ticket/50671.

pfefferle commented 4 years ago

@TimothyBJacobs thanks for the patch, this seems to fix our issue, but now some hosters receive translation issues: https://make.wordpress.org/hosting/test-results/r48561/sakurabot-r48561/

TimothyBJacobs commented 4 years ago

Glad that fixed it! I'm not sure what would cause that issue, probably worth opening a core ticket.

pfefferle commented 4 years ago

It seems that all tests are now green, so I will close this bug for now. Thanks @TimothyBJacobs for your help!

Please reopen if you still see some errors.