Giter Site home page Giter Site logo

phpunit-test-runner's Introduction

PHPUnit Test Runner

Thanks for running the WordPress PHPUnit test suite on your infrastructure. We appreciate you helping to ensure WordPress’s compatibility for your users.

If you haven't already, please first read through the "Getting Started" documentation.

The test suite runner is designed to be used without any file modification. Configuration happens with a series of environment variables (see .env.default for an annotated overview).

At a high level, the test suite runner:

  1. Prepares the test environment for the test suite.
  2. Runs the PHPUnit tests in the test environment.
  3. Reports the PHPUnit test results to WordPress.org
  4. Cleans up the test suite environment.

Setup

The test suite runner can be used in one of two ways:

  1. With GitHub Actions, (or Travis, Circle, or another CI service) as the controller that connects to the remote test environment.
  2. With the runner cloned to and run directly within the test environment.

The test runner is configured through environment variables, documented in .env.default. It shouldn't need any code modifications; in fact, please refrain from editing the scripts entirely, as it will make it easier to stay up to date.

With a direct Git clone, you can:

# Copy the default .env file.
cp .env.default .env
# Edit the .env file to define your variables.
vim .env
# Load your variables into scope.
source .env

In a CI service, you can set these environment variables through the service's web console. Importantly, the WPT_SSH_CONNECT environment variable determines whether the test suite is run locally or against a remote environment.

Concurrently run tests in the same environment by appending build ids to the test directory and table prefix:

export WPT_TEST_DIR=wp-test-runner-$TRAVIS_BUILD_NUMBER
export WPT_TABLE_PREFIX=wptests_$TRAVIS_BUILD_NUMBER\_

Connect to a remote environment over SSH by having the CI job provision the SSH key:

# 1. Create a SSH key pair for the controller to use
ssh-keygen -t rsa -b 4096 -C "[email protected]"
# 2. base64 encode the private key for use with the environment variable
cat ~/.ssh/id_rsa | base64 --wrap=0
# 3. Append id_rsa.pub to authorized_keys so the CI service can SSH in
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

Use a more complex SSH connection process by creating an SSH alias:

# 1. Add the following to ~/.ssh/config to create a 'wpt' alias
Host wpt
  Hostname 123.45.67.89
  User wpt
  Port 1234
# 2. Use 'wpt' wherever you might normally use a SSH connection string
ssh wpt

Running

The test suite runner is run in four steps. This explanation is for the local execution.

Requirements

To use the Runner, the following is required (testing WordPress 6.5):

  • Server / hosting (infrastructure) with the usual configuration you use
  • A database where you can test (tables will be created and destroyed several times)
  • PHP 7.0+ (view )
  • MySQL 5.5+ / MariaDB 10.0+
  • NodeJS 20.x / npm 10.x / grunt
  • PHP Composer
  • Git, RSync, WGet, UnZip

Test environment:

  • Writable filesystem for the entire test directory (see #40910).
  • Run with a non-root user, both for security and practical purposes (see #44233/#46577).

Database creation

This is an example for MySQL / MariaDB.

CREATE DATABASE wordpressdatabase CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci;
GRANT ALL ON wordpressdatabase.* TO 'wordpressusername'@'localhost' IDENTIFIED BY 'wordpresspassword';
GRANT ALL ON wordpressdatabase.* TO 'wordpressusername'@'127.0.0.1' IDENTIFIED BY 'wordpresspassword';
FLUSH PRIVILEGES;

NodeJS installation

This is an example for Debian / Ubuntu.

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt -y install nodejs
sudo npm install -g npm@latest
nodejs --version
npm --version

PHP Composer

This is an example for Debian / Ubuntu.

curl -sS https://getcomposer.org/installer -o composer-setup.php
php composer-setup.php --install-dir=/usr/local/bin --filename=composer
composer --version

Git

This is an example for Debian / Ubuntu.

apt -y install git
git --version

Installing the Test Runner

First, download the software. This example uses /home/wptestrunner/ folder, but set the best for this environment.

cd /home/wptestrunner/
git clone https://github.com/WordPress/phpunit-test-runner.git
cd phpunit-test-runner/

The next step will be to configure the environment. To do this, make a copy of the example file and then configure it.

cp .env.default .env
vim .env

The content (in summary form) can be something like this:

###
# Configuration environment variables used by the test runner
#
# # Create a copy for your local environment
# $ cp .env.default .env
#
# # Make any necessary changes to the default values
# $ vim .env
#
# # Load your variables into your environment
# $ source .env
###

# Path to the directory where files can be prepared before being delivered to the environment.
export WPT_PREPARE_DIR=/tmp/wp-test-runner

# Path to the directory where the WordPress develop checkout can be placed and tests can be run.
# When running tests in the same environment, set WPT_TEST_DIR to WPT_PREPARE_DIR
export WPT_TEST_DIR=/tmp/wp-test-runner

# API key to authenticate with the reporting service in 'username:password' format.
export WPT_REPORT_API_KEY=

# (Optionally) define an alternate reporting URL
export WPT_REPORT_URL=

# Credentials for a database that can be written to and reset.
# WARNING!!! This database will be destroyed between tests. Only use safe database credentials.
# Please note that you must escape _or_ refrain from using # as special character in your credentials.
export WPT_DB_NAME=
export WPT_DB_USER=
export WPT_DB_PASSWORD=
export WPT_DB_HOST=

# (Optionally) set a custom table prefix to permit concurrency against the same database.
export WPT_TABLE_PREFIX=${WPT_TABLE_PREFIX-wptests_}

# (Optionally) define the PHP executable to be called
export WPT_PHP_EXECUTABLE=${WPT_PHP_EXECUTABLE-php}

# (Optionally) define the PHPUnit command execution call.
# Use if `php phpunit.phar` can't be called directly for some reason.
export WPT_PHPUNIT_CMD=

# (Optionally) define the command execution to remove the test directory
# Use if `rm -r` can't be called directly for some reason.
export WPT_RM_TEST_DIR_CMD=

# SSH connection string (can also be an alias).
# Leave empty if tests are meant to run in the same environment.
export WPT_SSH_CONNECT=

# Any options to be passed to the SSH connection
# Defaults to '-o StrictHostKeyChecking=no'
export WPT_SSH_OPTIONS=

# SSH private key, base64 encoded.
export WPT_SSH_PRIVATE_KEY_BASE64=

# Output logging
# Use 'verbose' to increase verbosity
export WPT_DEBUG=

# Certificate validation
# Use 1 to validate, and 0 to not validate
export WPT_CERTIFICATE_VALIDATION=1

# WordPress flavor
# 0 = WordPress (simple version)
# 1 = WordPress Multisite
export WPT_FLAVOR=1

# Extra tests (groups)
# 0 = none
# 1 = ajax
# 2 = ms-files
# 3 = external-http
export WPT_EXTRATESTS=0

Configure the folder where the WordPress software downloads and the database accesses will be made in order to prepare the tests.

Preparing the environment

Before performing the first test, let’s update all the components. This process can be run before each test in this environment if wanted to keep it up to date, although it will depend more if it is in a production environment.

cd /home/wptestrunner/phpunit-test-runner/
git pull
source .env
git checkout master

If you want to check a different branch, you can change it doing:

git checkout example-branch

Preparing the test

Now there is the environment ready, run the test preparation.

php prepare.php

The system will run a long series of installations, configurations and compilations of different elements in order to prepare the test. If warnings and warnings come out you should not worry too much, as it is quite normal. At the end of the process it will warn you if it needs something it doesn’t have. If it works, you should see something like this at the end:

Success: Prepared environment.

Now that the environment has been prepared, the next step is to run the tests for the first time.

Running the test

Now that the environment is ready, let’s run the tests. To do this, execute the file that will perform it.

php test.php

What do the symbols mean?

. → Each dot means that the test has been passed correctly.

S → It means the test has been skipped. This is usually because these tests are only valid in certain configurations.

F → Means that the test has failed. Information about why this happened is displayed at the end.

E → It means that the test has failed due to a PHP error, which can be an error, warning or notice.

I → Means that the test has been marked as incomplete.

If you follow these steps, everything should work perfectly and not make any mistakes. In case you get any error, it may be normal due to some missing adjustment or extension of PHP, among others. We recommend that you adjust the configuration until it works correctly. After all, this tool is to help you improve the optimal configuration for WordPress in that infrastructure.

Creating a report

Even if the test has failed, a report will be made. The first one shows the information about our environment. Among the most important elements are the extensions that are commonly used in WordPress and some utilities that are also generally useful.

cat /tmp/wp-test-runner/tests/phpunit/build/logs/env.json

The content of this file is somewhat similar to this:

{
  "php_version": "7.4.5",
  "php_modules": {
    "bcmath": false,
    "curl": "7.4.5",
    "filter": "7.4.5",
    "gd": false,
    "libsodium": false,
    "mcrypt": false,
    "mod_xml": false,
    "mysqli": "7.4.5",
    "imagick": false,
    "pcre": "7.4.5",
    "xml": "7.4.5",
    "xmlreader": "7.4.5",
    "zlib": "7.4.5"
  },
  "system_utils": {
    "curl": "7.58.0 (x86_64-pc-linux-gnu) libcurl\/7.58.0 OpenSSL\/1.1.1g zlib\/1.2.11 libidn2\/2.3.0 libpsl\/0.19.1 (+libidn2\/2.0.4) nghttp2\/1.30.0 librtmp\/2.3",
    "ghostscript": "",
    "imagemagick": false,
    "openssl": "1.1.1g 21 Apr 2020"
  },
  "mysql_version": "mysql Ver 15.1 Distrib 10.4.12-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2",
  "os_name": "Linux",
  "os_version": "4.15.0-20-generic"
}

In addition to this report, a definitive file with all the information of what happened in the tests. This is the one that includes all the tests that are made (more than 10,000) giving information of the time that they take to be executed, problems that have arisen…

cat /tmp/wp-test-runner/tests/phpunit/build/logs/junit.xml

At this point we can generate the reports by sending them to WordPress.org, if necessary. Even if you haven’t included the WordPress user (see below for how to create it), you can still run this file.

php report.php

Cleaning up the environment for other tests

Having the tests working, all that remains is to delete all the files that have been created so that we can start over. To do this, execute the following command:

php cleanup.php

Automatic running

The best way to run this test is to create a cron that runs everything. Having in mind that the tests can overlap, the best way can be using a systemd timer.

cat > /etc/systemd/system/wordpressphpunittestrunner.service << EOF
[Unit]
Description=WordPress PHPUnit Test Runner
[Service]
Type=oneshot
ExecStart=cd /home/wptestrunner/phpunit-test-runner/ && source .env && php prepare.php && php test.php && php report.php && php cleanup.php
User=wptestrunner
Group=wptestrunner
EOF
cat > /etc/systemd/system/wordpressphpunittestrunner.timer << EOF
[Unit]
Description=WordPress PHPUnit Test Runner
[Timer]
OnCalendar=*-*-* *:*:00
Persistent=true
[Install]
WantedBy=timers.target
EOF
systemctl daemon-reload
systemctl enable wordpressphpunittestrunner.timer
systemctl start wordpressphpunittestrunner.timer
systemctl status wordpressphpunittestrunner.timer

If you want to check how is everything working...

journalctl -u wordpressphpunittestrunner.timer
journalctl -n 120 -u wordpressphpunittestrunner.service

Contributing

If you have questions about the process or run into test failures along the way, please open an issue in the project repository and we’ll help diagnose/get the documentation updated. Alternatively, you can also pop into the #hosting channel on WordPress.org Slack for help.

License

See LICENSE for project license.

phpunit-test-runner's People

Contributors

adamsilverstein avatar akkspros avatar crixu avatar danielbachhuber avatar desrosj avatar earnjam avatar fedealvz avatar getsource avatar grooverdan avatar ironprogrammer avatar javiercasares avatar mrxkon avatar octalmage avatar pento avatar pfefferle avatar pkevan avatar pmbaldha avatar swissspidy avatar timbutler avatar wpscholar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phpunit-test-runner's Issues

Documentation Improvements

The configuration directions imply that someone can use Travis, but offer no explicit walkthroughs as to how one might do so. This is made more complicated by the fact that installation directions are muddled with configurations, and in neither case are the two actually detailed.

This should be changed to something like the following:

0 . Requirements

Move this UP from hidden down in 'running' :) If you HAVE to have these things, get them installed first.

  1. Installation Instructions

What has to be installed? One presumes you always want to gitclone, but this isn't expressly stated. This would have the "How to install the runner scripts" (git clone?) and then a subsection for Travis on the SSH stuff.

If there are different directions for Travis vs local, then break the sections apart clearly.

  1. Configuration

Here, we should offer some help for newbies. Travis. Cool! What does that mean? :) We may eventually need an example (use the wiki?) for a walk through of how someone sets up Travis.

This is where we separate Local and Travis/CI again.

In a CI service, you can set these environment variables through the service's web console. Importantly, the WPT_SSH_CONNECT environment variable determines whether the test suite is run locally or against a remote environment.

There's not enough detail there for someone to understand what that means without the explanations of what a CI is for. Even just an example of "For Travis you want..." will get people started.

  1. Prepare

This can be as is, though it would help to explicitly state "Run the command with php prepare.php as a normal user (i.e. not ROOT)" - this should be obvious, but it may not be.

  1. Running

It's not actually clear that you want to run the test and report commands sequentially, so here we need to step back and explain that test.php actually runs a test. This is the thing you're trying to get to :)

Under that you could have a subsection for reporting. "If you're going to automagically send the report to somewhere, like WordPress.org (link to that handbook), you'll need to use this." Explicitly state what values need to be set and where in the .env file for that if you can.

  1. Cleanup

There's no information WHY a person would want to run this. Is this for uninstall? Should I always run it after the report? If it's uninstall, let's explain that. If it's meant to run every time, then put it up with the running section.

  1. Automation

FUN TIME! We don't explain this at all :D It should probably be a wiki page instead of in the readme, but we should offer some examples like "If you're using local and want to cron this every X hours..." That would let us have a whole Travis-CI section AND let other people contribute 'how to with this CI thingy' as well.

Log results of reporting API interactions

When a POST request to the reporting API is successful, the script should display the permalink (or post ID or some identifying factor) for the saved report.

When a POST request to the reporting API fails, we should display the HTTP status code and error message returned (for debugging purposes).

From #14

Support both ImageMagick and GraphicsMagic

GraphicsMagic is an improved fork of ImageMagic. WordPress works with both and this tester should support both of them. Currently it does not, because it runs convert and convert --version and not at all gm convert or gm version.

PHP error when running php prepare.php immediately after cloning, before creating .env file

While experimenting with the PHP unit test runner, I found that PHP 5.6 and PHP 7.0 encounter a fatal PHP error when the command php prepare.php is run immediately after cloning, before creating a local .env file. PHP recorded the following error in the error log:
[28-Aug-2017 14:46:52 UTC] PHP Warning: fwrite() expects parameter 1 to be resource, string given in /path/to/public_html/phpunit-test-runner/functions.php on line 64

The actual command returned the following output:
Content-type: text/html; charset=UTF-8

Not necessarily a huge issue, but it may be worthwhile to add error catching for this use case since the test suite provides more informative feedback in other problematic situations, such as when needed environment vars are not defined in .env or in the environment.

Bluehost test runner.

Bluehost just got the test runner running on our platform. Our wp.org username is bluehostbot.

Thanks!

Add locking mechanism

At the beginning of every test run, the runner should write a lock file to the test environment. Then, at the end of the test run, the runner should clear the lock file.

Similarly, at the beginning of every test run, the runner should check for the presence of a lock file. If the lock file exists, then the runner should bail on the test run.

This lock file helps prevent two test runner processes from using the same environment at the same time (which would produce inconsistent reporting results).

Research and document what can cause variance in test execution time

mike [10:24 AM] I did have someone ask internally about test times
danielbachhuber [10:25 AM] oh yeah, I saw that too
mike [10:25 AM] And explained that test times don’t directly indicate the performance of a WordPress solution
[10:25] But that might not be clear to everyone
danielbachhuber [10:25 AM] it'd be interesting to know what can cause the variance in execution time
jadonn [10:25 AM] That probably could be made more clear. For me, the test times were more of an academic curiosity than a practical concern

PHP Unit Test

Hi there,

I'm Mustaasam from Cloudways - A Managed Cloud hosting platform.

I'm conducting the WordPress PHP Unit Test as guided here and followed by GitHub.

For the purpose, I need to be added as a “Test Reporter” on WordPress.org site. Here is the email for WordPress.org account: [email protected]

Looking forward to it.

Thanks!

Failures details in default testsuite not reported due to core unit test changes

I noticed yesterday that errors/failures were not showing the specific failures in the single-result view properly. Example:
https://make.wordpress.org/hosting/test-results/r44742/wpdevbot-r44742/

In https://core.trac.wordpress.org/changeset/43768 we added unit tests for the new autosave REST API endpoint. Because of the DOING_AUTOSAVE polluting tests, they had to be separated out and run last. This essentially leads to two root level testsuites, which process_junit_xml() isn't accounting for.

image

There is a core ticket for addressing the unit tests specifically, but wondering if we should better handle it here to be less brittle too. https://core.trac.wordpress.org/ticket/45132

How to specify SSH/rsync port.

It might be useful to allow supplying the full SSH command, and this could be used for the rsync like this:

 rsync -avz -e "ssh -p $portNumber" user@remoteip:/path/to/files/ /local/path/

It would be awesome if the ssh command could be used for both ssh and rsync.

Please Add my Test Reporter

I performed the test and the result is here, Please let me know if its good to go


You should really fix these slow tests (>150ms)...

  1. 2823ms to run Tests_Media:test_multiline_comment_with_embeds
  2. 1855ms to run Tests_WP_Site_Icon:test_insert_cropped_attachment
  3. 1706ms to run WP_Test_REST_Users_Controller:test_get_items_pagination_headers
  4. 1576ms to run Tests_Image_Functions:test_wp_crop_image_url
  5. 1504ms to run Tests_Media:test_autoembed_no_paragraphs_around_urls
  6. 1252ms to run Tests_Media:test_oembed_explicit_media_link
  7. 1139ms to run WP_Test_REST_Posts_Controller:test_get_items_pagination_headers
  8. 1082ms to run Tests_Image_Functions:test_inferred_mime_types
  9. 968ms to run Tests_WP_Site_Icon:test_create_attachment_object
  10. 950ms to run Tests_Import_Import:test_double_import
    ...and there are 194 more above your threshold hidden from view

Time: 5.57 minutes, Memory: 403.25MB

OK, but incomplete, skipped, or risky tests!
Tests: 8702, Assertions: 36182, Skipped: 6, Risky: 8.

Please add our Test Reporter

Hello,
We would like to send the test report to your system. The WordPress.org account details :
Email : triyadi at rumahweb.co.id
username : rumahwebbot

Git version is required to be 1.8.5 or above

Currently, the software requires git version 1.8.5 or above. This is important as CentOS does not currently have a compatible version.

The issue is caused by the -C option which is used by report.php:

Line 19:

$rev = exec('git -C ' . escapeshellarg( $WPT_PREPARE_DIR ) . ' log -1 --pretty=%B | grep "git-svn-id:" | cut -d " " -f 2 | cut -d "@" -f 2');

Line 22:

$message = trim( exec('git -C ' . escapeshellarg( $WPT_PREPARE_DIR ) . ' log -1 --pretty=%B | head -1') );

node-sass seems to use it as well, but those are the only places where I see it being used.

Regarding the specific versions, you can see that the -C option (not to be confused with the -c option) was not present in 1.8.4.5:

https://www.git-scm.com/docs/git/1.8.4.5

It is present in 1.8.5, and versions after:

https://www.git-scm.com/docs/git/1.8.5

CentOS 7 (I am testing on 7.5.1804) has git version 1.8.3.1. However, I am also testing on a cPanel server, and when run using cPanel's git version, it is 2.19.1, which works fine.

I would recommend either adding the version to the software requirements, or perhaps looking at potentially removing the -C option if possible.

Unknown storage engine MyISAM (first time test run)

Hello,

I just got our testing server running and executed the first time tests and it appeared to have failed (https://make.wordpress.org/hosting/test-results/r45108/wpcloudbot-r45108/)

During the test.php running I get lots of errors due to specification of DB creation with "ENGINE=MyISAM".
We have MariaDB Galera Cluster in use, which only supports InnoDB (forced) as the engine and therefore gives an error message of unsupported DB engine.

$ php test.php
Environment variables pass checks.
cd '/tmp/wp-test-runner'; php phpunit.phar

PHP version: 7.3.3-1+ubuntu18.04.1+deb.sury.org+1 (/usr/bin/php7.3)

Installing...
Running as single site... To run multisite, use -c tests/phpunit/multisite.xml
Not running ajax tests. To execute these, use --group ajax.
Not running ms-files tests. To execute these, use --group ms-files.
Not running external-http tests. To execute these, use --group external-http.
PHPUnit 5.7.27 by Sebastian Bergmann and contributors.

.............................................................   61 / 9562 (  0%)
.............................................................  122 / 9562 (  1%)
.............................................................  183 / 9562 (  1%)
.............................................................  244 / 9562 (  2%)
.............................................................  305 / 9562 (  3%)
.............................................................  366 / 9562 (  3%)
.............................................................  427 / 9562 (  4%)
.............................................................  488 / 9562 (  5%)
.............................................................  549 / 9562 (  5%)
.............................................................  610 / 9562 (  6%)
.............................................................  671 / 9562 (  7%)
.............................................................  732 / 9562 (  7%)
.............................................................  793 / 9562 (  8%)
.............................................................  854 / 9562 (  8%)
.............................................................  915 / 9562 (  9%)
.............................................................  976 / 9562 ( 10%)
............................................................. 1037 / 9562 ( 10%)
............................................................. 1098 / 9562 ( 11%)
............................................................. 1159 / 9562 ( 12%)
............................................................. 1220 / 9562 ( 12%)
............................................................. 1281 / 9562 ( 13%)
............................................................. 1342 / 9562 ( 14%)
............................................................. 1403 / 9562 ( 14%)
............................................................. 1464 / 9562 ( 15%)
............................................................. 1525 / 9562 ( 15%)
............................................................. 1586 / 9562 ( 16%)
............................................................. 1647 / 9562 ( 17%)
............................................................. 1708 / 9562 ( 17%)
............................................................. 1769 / 9562 ( 18%)
............................................................. 1830 / 9562 ( 19%)
............................................................. 1891 / 9562 ( 19%)
............................................................. 1952 / 9562 ( 20%)
............................................................. 2013 / 9562 ( 21%)
............................................................. 2074 / 9562 ( 21%)
.....................S....................................... 2135 / 9562 ( 22%)
............................................................. 2196 / 9562 ( 22%)
............................................................. 2257 / 9562 ( 23%)
............................................................. 2318 / 9562 ( 24%)
............................................................. 2379 / 9562 ( 24%)
...................S.S....................................... 2440 / 9562 ( 25%)
............................................................. 2501 / 9562 ( 26%)
..........................S.................................. 2562 / 9562 ( 26%)
.......................WordPress database error Unknown storage engine 'MyISAM' for query
                        CREATE TABLE wptests__dbdelta_test (
                                id bigint(20) NOT NULL AUTO_INCREMENT,
                                column_1 varchar(255) NOT NULL,
                                column_2 text,
                                column_3 blob,
                                PRIMARY KEY  (id),
                                KEY key_1 (column_1(191)),
                                KEY compound_key (id,column_1(191)),
                                FULLTEXT KEY fulltext_key (column_1)
                        ) ENGINE=MyISAM
                         made by PHPUnit_TextUI_Command::main, PHPUnit_TextUI_Command->run, PHPUnit_TextUI_TestRunner->doRun, PHPUnit_Framework_TestSuite->run, PHPUnit_Framework_TestSuite->run, PHPUnit_Framework_TestSuite->run, PHPUnit_Framework_TestCase->run, PHPUnit_Framework_TestResult->run, PHPUnit_Framework_TestCase->runBare, Tests_dbDelta->setUp
.<div id="error"><p class="wpdberror"><strong>WordPress database error:</strong> [Unknown storage engine &#039;MyISAM&#039;]<br /><code>

**Lot's of those repeating**

......
You should really fix these slow tests (>150ms)...
 1. 1018ms to run WP_Test_REST_Users_Controller:test_get_items_pagination_headers
 2. 789ms to run Tests_Media:test_oembed_explicit_media_link
 3. 668ms to run Tests_Media:test_multiline_comment_with_embeds
 4. 598ms to run WP_Test_REST_Posts_Controller:test_get_items_pagination_headers
 5. 595ms to run Tests_Image_Functions:test_inferred_mime_types
 6. 493ms to run WP_Test_REST_Users_Controller:test_get_items_per_page
 7. 488ms to run Tests_WP_Customize_Manager:test_import_theme_starter_content
 8. 476ms to run WP_Test_REST_Users_Controller:test_get_items_page
 9. 461ms to run Tests_Import_Import:test_double_import
 10. 453ms to run Tests_WP_Site_Icon:test_insert_cropped_attachment
...and there are 35 more above your threshold hidden from view

Time: 2.66 minutes, Memory: 186.50MB

There was 1 error:

1) Tests_Image_Functions::test_pdf_preview_doesnt_overwrite_existing_jpeg
Undefined index: sizes

/tmp/wp-test-runner/tests/phpunit/tests/image/functions.php:620

--

There were 26 failures:

1) Tests_dbDelta::test_existing_table
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
+    'wptests__dbdelta_test' => 'Created table wptests__dbdelta_test'
 )

/tmp/wp-test-runner/tests/phpunit/tests/dbdelta.php:121

2) Tests_dbDelta::test_column_type_change
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
-    'wptests__dbdelta_test.id' => 'Changed type of wptests__dbde...nt(11)'
+    'wptests__dbdelta_test' => 'Created table wptests__dbdelta_test'
 )

/tmp/wp-test-runner/tests/phpunit/tests/dbdelta.php:147

3) Tests_dbDelta::test_column_added
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
-    'wptests__dbdelta_test.extra_col' => 'Added column wptests__dbdelta...ra_col'
+    'wptests__dbdelta_test' => 'Created table wptests__dbdelta_test'
 )

/tmp/wp-test-runner/tests/phpunit/tests/dbdelta.php:176

4) Tests_dbDelta::test_columns_arent_removed
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
+    'wptests__dbdelta_test' => 'Created table wptests__dbdelta_test'
 )

/tmp/wp-test-runner/tests/phpunit/tests/dbdelta.php:206

5) Tests_dbDelta::test_no_execution
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
-    'wptests__dbdelta_test.extra_col' => 'Added column wptests__dbdelta...ra_col'
+    'wptests__dbdelta_test' => 'Created table wptests__dbdelta_test'
 )

/tmp/wp-test-runner/tests/phpunit/tests/dbdelta.php:236

6) Tests_dbDelta::test_insert_into_table
null does not match expected type "object".

/tmp/wp-test-runner/tests/phpunit/tests/dbdelta.php:308
/tmp/wp-test-runner/tests/phpunit/tests/dbdelta.php:259

7) Tests_dbDelta::test_fulltext_index
Failed asserting that an array is empty.

/tmp/wp-test-runner/tests/phpunit/tests/dbdelta.php:285

8) Tests_dbDelta::test_dont_downsize_text_fields
Failed asserting that Array &0 (
    'wptests__dbdelta_test' => 'Created table wptests__dbdelta_test'
) is identical to Array &0 ().

/tmp/wp-test-runner/tests/phpunit/tests/dbdelta.php:425

9) Tests_dbDelta::test_dont_downsize_blob_fields
Failed asserting that Array &0 (
    'wptests__dbdelta_test' => 'Created table wptests__dbdelta_test'
) is identical to Array &0 ().

/tmp/wp-test-runner/tests/phpunit/tests/dbdelta.php:450

10) Tests_dbDelta::test_upsize_text_fields
Failed asserting that Array &0 (
    'wptests__dbdelta_test' => 'Created table wptests__dbdelta_test'
) is identical to Array &0 (
    'wptests__dbdelta_test.column_2' => 'Changed type of wptests__dbdelta_test.column_2 from text to bigtext'
).

/tmp/wp-test-runner/tests/phpunit/tests/dbdelta.php:478

11) Tests_dbDelta::test_upsize_blob_fields
Failed asserting that Array &0 (
    'wptests__dbdelta_test' => 'Created table wptests__dbdelta_test'
) is identical to Array &0 (
    'wptests__dbdelta_test.column_3' => 'Changed type of wptests__dbdelta_test.column_3 from blob to mediumblob'
).

/tmp/wp-test-runner/tests/phpunit/tests/dbdelta.php:509

12) Tests_dbDelta::test_spatial_indices
Failed asserting that an array is empty.

/tmp/wp-test-runner/tests/phpunit/tests/dbdelta.php:563

13) Tests_dbDelta::test_index_with_a_reserved_keyword_can_be_created
Failed asserting that actual size 0 matches expected size 2.

/tmp/wp-test-runner/tests/phpunit/tests/dbdelta.php:643

14) Tests_dbDelta::test_key_and_index_and_fulltext_key_and_fulltext_index_and_unique_key_and_unique_index_indicies
Failed asserting that Array &0 (
    'wptests__dbdelta_test' => 'Created table wptests__dbdelta_test'
) is identical to Array &0 (
    0 => 'Added index wptests__dbdelta_test KEY `key_2` (`column_1`(191))'
    1 => 'Added index wptests__dbdelta_test UNIQUE KEY `key_3` (`column_1`(191))'
    2 => 'Added index wptests__dbdelta_test UNIQUE KEY `key_4` (`column_1`(191))'
    3 => 'Added index wptests__dbdelta_test FULLTEXT KEY `key_5` (`column_1`)'
).

/tmp/wp-test-runner/tests/phpunit/tests/dbdelta.php:689

15) Tests_dbDelta::test_index_and_key_are_synonyms_and_do_not_recreate_indices
Failed asserting that an array is empty.

/tmp/wp-test-runner/tests/phpunit/tests/dbdelta.php:722

16) Tests_dbDelta::test_indices_with_prefix_limits_are_created_and_do_not_recreate_indices
Failed asserting that Array &0 (
    'wptests__dbdelta_test' => 'Created table wptests__dbdelta_test'
) is identical to Array &0 (
    0 => 'Added index wptests__dbdelta_test KEY `key_2` (`column_1`(10))'
    1 => 'Added index wptests__dbdelta_test KEY `key_3` (`column_2`(100),`column_1`(10))'
).

/tmp/wp-test-runner/tests/phpunit/tests/dbdelta.php:749

17) Tests_dbDelta::test_index_col_names_with_order_do_not_recreate_indices
Failed asserting that an array is empty.

/tmp/wp-test-runner/tests/phpunit/tests/dbdelta.php:780

18) Tests_dbDelta::test_primary_key_with_single_space_does_not_recreate_index
Failed asserting that an array is empty.

/tmp/wp-test-runner/tests/phpunit/tests/dbdelta.php:804

19) Tests_dbDelta::test_index_definitions_with_spaces_do_not_recreate_indices
Failed asserting that an array is empty.

/tmp/wp-test-runner/tests/phpunit/tests/dbdelta.php:828

20) Tests_dbDelta::test_index_types_are_not_case_sensitive_and_do_not_recreate_indices
Failed asserting that an array is empty.

/tmp/wp-test-runner/tests/phpunit/tests/dbdelta.php:852

21) Tests_dbDelta::test_key_names_are_not_case_sensitive_and_do_not_recreate_indices
Failed asserting that an array is empty.

/tmp/wp-test-runner/tests/phpunit/tests/dbdelta.php:877

22) Tests_dbDelta::test_unchanged_key_lengths_do_not_recreate_index
Failed asserting that an array is empty.

/tmp/wp-test-runner/tests/phpunit/tests/dbdelta.php:902

23) Tests_dbDelta::test_changed_key_lengths_do_not_recreate_index
Failed asserting that Array &0 (
    'wptests__dbdelta_test' => 'Created table wptests__dbdelta_test'
) is identical to Array &0 (
    0 => 'Added index wptests__dbdelta_test KEY `changing_key_length` (`column_1`(20))'
).

/tmp/wp-test-runner/tests/phpunit/tests/dbdelta.php:929

24) Tests_Image_Functions::test_wp_generate_attachment_metadata_pdf
Failed asserting that Array &0 () is identical to Array &0 (
    'sizes' => Array &1 (
        'thumbnail' => Array &2 (
            'file' => 'wordpress-gsoc-flyer-pdf-116x150.jpg'
            'width' => 116
            'height' => 150
            'mime-type' => 'image/jpeg'
        )
        'medium' => Array &3 (
            'file' => 'wordpress-gsoc-flyer-pdf-232x300.jpg'
            'width' => 232
            'height' => 300
            'mime-type' => 'image/jpeg'
        )
        'large' => Array &4 (
            'file' => 'wordpress-gsoc-flyer-pdf-791x1024.jpg'
            'width' => 791
            'height' => 1024
            'mime-type' => 'image/jpeg'
        )
        'full' => Array &5 (
            'file' => 'wordpress-gsoc-flyer-pdf.jpg'
            'width' => 1088
            'height' => 1408
            'mime-type' => 'image/jpeg'
        )
    )
).

/tmp/wp-test-runner/tests/phpunit/tests/image/functions.php:466

25) Tests_Image_Functions::test_crop_setting_for_pdf
Failed asserting that Array &0 () is identical to Array &0 (
    'sizes' => Array &1 (
        'thumbnail' => Array &2 (
            'file' => 'wordpress-gsoc-flyer-pdf-116x150.jpg'
            'width' => 116
            'height' => 150
            'mime-type' => 'image/jpeg'
        )
        'medium' => Array &3 (
            'file' => 'wordpress-gsoc-flyer-pdf-300x300.jpg'
            'width' => 300
            'height' => 300
            'mime-type' => 'image/jpeg'
        )
        'large' => Array &4 (
            'file' => 'wordpress-gsoc-flyer-pdf-791x1024.jpg'
            'width' => 791
            'height' => 1024
            'mime-type' => 'image/jpeg'
        )
        'full' => Array &5 (
            'file' => 'wordpress-gsoc-flyer-pdf.jpg'
            'width' => 1088
            'height' => 1408
            'mime-type' => 'image/jpeg'
        )
    )
).

/tmp/wp-test-runner/tests/phpunit/tests/image/functions.php:531

26) Tests_Image_Functions::test_fallback_intermediate_image_sizes
The `test-size` was not added to the metadata.
Failed asserting that false is true.

/tmp/wp-test-runner/tests/phpunit/tests/image/functions.php:572

ERRORS!
Tests: 9562, Assertions: 73759, Errors: 1, Failures: 26, Skipped: 14.
Error: Failed to perform operation.

Reuse of file names restricts concurrent runs

This is more of a feature request, and may be similar to issues #1 and #6, but I feel the scope may be different then the resolutions mentioned there.

I have found that I receive errors, or have the potential for inconsistent results if I am running multiple instances concurrently, or if previous tests failed. Specifically, I am seeing that certain file names are being reused for multiple tests. Some example names include:

/tmp/waffles-300x225.jpg
/tmp/waffles.jpg
/tmp/canola.jpg
/tmp/canola-150x150.jpg

As you could suspect from the directory, on my system the temp directory is set globally to /tmp, which means that if two different users attempt to run the tests at the same time, it fails because of user permissions issues. The symptoms may not be important for most people, as they are likely using only a single user to run the tests on a given machine. However, as I have seen those files remaining after certain runs, perhaps after a failed run, I had suspected that they might cause problems if they remain until the next run for that same user.

In my environments, I am running the scripts directly on certain servers which will be hosting WordPress with the intention of having more accurate results.

If this is a problem, I would recommend adding some other information onto the file names, perhaps such as a hash value, or perhaps by adding in an ID for the run.

AMIMOTO Test Reporter

Hey!

We'd like to complete our test reporter setup. The info we've registered for this at WP.org is the following:

Username Email
amimotobot [email protected]

Thanks, Dan

Please add conetixbot for test reporting

Hi,

We have server configured with our typical settings configured with the unit tests ready to report. The wordpress.org username is conetixbot and the email associated is [email protected].

Please just let me know if there's any additional information required.

Research and document slow/risky tests

danielbachhuber [10:17 AM] I'd like to spend a little bit of time looking at the "slow" and "risky" tests to see if we can do anything about them
[10:18] to someone not intimately involved with core development, slow/risky tests seem like an issue with the environment, not core

Error: Error uploading results: Invalid parameter(s): commit, message (HTTP status 400)

I performed the final reporting

and run following command gives me error in uploading result.

php report.php


Environment variables pass checks.
Getting SVN Revision
Unknown option: -C
usage: git [--version] [--help] [-c name=value]
[--exec-path[=]] [--html-path] [--man-path] [--info-path]
[-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
[--git-dir=] [--work-tree=] [--namespace=]
[]
Getting SVN message
Unknown option: -C
usage: git [--version] [--help] [-c name=value]
[--exec-path[=]] [--html-path] [--man-path] [--info-path]
[-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
[--git-dir=] [--work-tree=] [--namespace=]
[]
Copying junit.xml results
rsync -rv '/tmp/wp-test-runner'/tests/phpunit/build/logs/* '/tmp/wp-test-runner'
sending incremental file list
env.json
junit.xml

sent 1,626,388 bytes received 54 bytes 3,252,884.00 bytes/sec
total size is 1,625,842 speedup is 1.00
Processing and uploading junit.xml
Error: Error uploading results: Invalid parameter(s): commit, message (HTTP status 400)


Support both MySQL and MariaDB

Currently the test suite emits:

WordPress database error The storage engine InnoDB doesn't support SPATIAL indexes for query CREATE TEMPORARY TABLE wptests_spatial_index_test (
				non_spatial bigint(20) unsigned NOT NULL,
				spatial_value geometrycollection NOT NULL,
				KEY non_spatial (non_spatial),
				SPATIAL KEY spatial_key (spatial_value)
			) ENGINE=MyISAM; made by PHPUnit_TextUI_Command::main, PHPUnit_TextUI_Command->run, PHPUnit_TextUI_TestRunner->doRun, PHPUnit_Framework_TestSuite->run, PHPUnit_Framework_TestSuite->run, PHPUnit_Framework_TestCase->run, PHPUnit_Framework_TestResult->run, PHPUnit_Framework_TestCase->runBare, PHPUnit_Framework_TestCase->runTest, ReflectionMethod->invokeArgs, Tests_dbDelta->test_spatial_indices
F<div id="error"><p class="wpdberror"><strong>WordPress database error:</strong> [The storage engine InnoDB doesn&#039;t support SPATIAL indexes]<br /><code>CREATE TEMPORARY TABLE wptests_spatial_index_test (
				non_spatial bigint(20) unsigned NOT NULL,
				spatial_value geometrycollection NOT NULL,
				KEY non_spatial (non_spatial),
				SPATIAL KEY spatial_key (spatial_value)
			) ENGINE=MyISAM;

and

1) Tests_dbDelta::test_spatial_indices
Failed asserting that an array is empty.

I have not deeply researched this, but it seems to be related that certain MySQL-specific SQL statements are used, which are not part of the SQL standard and are not available on MariaDB. This should be handled in some way that both MySQL and MariaDB are supported.

Cleanup tripped up by node_modules/.cache

cleanup.php gets tripped up by some write-protected cache files in node_modules.

Essentially stuff like:
/wp-test-runner/node_modules/.cache/terser-webpack-plugin/content-v2/sha512/1c/1e/f8fc5f6bb74209f99461f090fbb9a7a31a5fc1ffdb3bf8beec44bc0df9052d42139d4060c781a6d161c7f43980403ab0f1b39a159dcca0e323c73e572e65'

We should probably add something like this before attempting to remove the prepare directory itself:
'rm -rf ' . escapeshellarg( $WPT_PREPARE_DIR . '/node_modules/.cache' )

Document use of ~/.ssh/config in README

For custom WPT_SSH_CONNECT configuration options, using ~/.ssh/config to define the options along with an alias can be quite helpful. We should document this in the README.

SAKURA_WebHosting Test Reporter

Hey!

We'd like to complete our test reporter setup. The info we've registered for this at WP.org is the following:

Username Email
hollyroyaltea emperor.kurt at gmail.com

test.php wastes CPU cycles and bandwith downloading PHPUnit every time

I noticed that running php test.php downloads PHPUnit on every run, even if phpunit is already in the system and even if phpunit.phar has already been downloaded.

$ phpunit --version
PHPUnit 5.7.27 by Sebastian Bergmann and contributors.

$ ll -h /tmp/wp-test-runner/phpunit.phar 
-rw-rw-r-- 1 benchmark benchmark 2.9M Feb  1 07:56 /tmp/wp-test-runner/phpunit.phar

$ php test.php
Environment variables pass checks.
cd '/tmp/wp-test-runner'; php phpunit.phar

PHP version: 7.0.30-1+ubuntu14.04.1+deb.sury.org+1 (/usr/bin/php7.0)

Installing...
Running as single site... To run multisite, use -c tests/phpunit/multisite.xml
Not running ajax tests. To execute these, use --group ajax.
Not running ms-files tests. To execute these, use --group ms-files.
Not running external-http tests. To execute these, use --group external-http.
PHPUnit 5.7.27 by Sebastian Bergmann and contributors.

.............................................................   61 / 8703 (  0%)
.............................................................  122 / 8703 (  1%)
.............................................................  183 / 8703 (  2%)
.............................................................  244 / 8703 (  2%)
.............................................................  305 / 8703 (  3%)
.............................................................  366 / 8703 (  4%)
.............................................................  427 / 8703 (  4%)
.............................................................  488 / 8703 (  5%)
.............................................................  549 / 8703 (  6%)
.............................................................  610 / 8703 (  7%)
.............................................................  671 / 8703 (  7%)
.............................................................  732 / 8703 (  8%)
.............................................................  793 / 8703 (  9%)
....

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.