You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 0a5404b
Browse filesBrowse the repository at this point in the historyBrowse files
Set `WP_CLI_TEST_PARALLEL` to a number of workers to spread the scenarios over that many Behat processes:
260
+
```bash
261
+
WP_CLI_TEST_PARALLEL=4 composer behat
262
+
```
263
+
264
+
Every worker but the first gets its own temporary directory, and with it its own home directory, caches and run directories, as well as its own test database, named after the test database with a numeric suffix (`wp_cli_test_1`, `wp_cli_test_2`, ...). Run `composer prepare-tests` once to allow the test user to create these databases. Without that permission, the scenarios are run one after the other, as they are on Windows, when collecting code coverage, or when selecting scenarios by path or name.
265
+
266
+
Scenarios that rely on resources shared across the system, such as a fixed port or a fixed path in the system's temporary directory, are all run by the first worker, one after the other. `composer behat-rerun` re-runs exactly the scenarios that failed in the last parallel run.
267
+
268
+
Set `WP_CLI_TEST_DOCKER` to run the scenarios in throwaway Docker containers instead, every worker in its own:
| not set (default), `0`, `no`, `off`| The scenarios run without Docker. |
276
+
|`auto`| The scenarios run in containers where possible, and without Docker otherwise, which is reported. |
277
+
|`1`, `yes`, `on`| The scenarios run in containers, and the run fails where that is not possible. |
278
+
279
+
Docker is not used on Windows, when collecting code coverage, when Docker is not available, when the image cannot be built or when the database server cannot be identified.
280
+
281
+
Each worker gets its own network, temporary directory and database server, of the same type and version as the one configured through the `WP_CLI_TEST_DB*` variables (or set the image through `WP_CLI_TEST_DOCKER_DB`, e.g. `mysql:8.0`, so that the host needs neither a database server nor a client). Nothing is shared between workers, so they can run any scenario. The database servers keep their data in memory. Scenarios selected by path or name run in a single container.
282
+
283
+
The containers run the same PHP version as the host, unless `WP_CLI_TEST_DOCKER_PHP` sets another one:
The project's Composer dependencies are then installed for that PHP version in a separate directory, the way CI installs them without a lock file, and refreshed once a day. Dependencies that are linked to local checkouts, as in `wp-cli/wp-cli-dev`, come from their published versions in that case, which is reported.
Copy file name to clipboardExpand all lines: bin/install-package-tests
+6Lines changed: 6 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -150,6 +150,8 @@ install_mysql_db_8_0_plus() {
150
150
${CLIENT_BINARY} -e "CREATE USER IF NOT EXISTS \`${TEST_USER}\`@'%' IDENTIFIED WITH caching_sha2_password BY '${TEST_PASSWORD}'"${HOST_STRING} -u"${USER}""${PASSWORD_STRING}"
151
151
${CLIENT_BINARY} -e "GRANT ALL PRIVILEGES ON \`${TEST_DB}\`.* TO '${TEST_USER}'@'%'"${HOST_STRING} -u"${USER}""${PASSWORD_STRING}"
152
152
${CLIENT_BINARY} -e "GRANT ALL PRIVILEGES ON \`${TEST_DB}_scaffold\`.* TO '${TEST_USER}'@'%'"${HOST_STRING} -u"${USER}""${PASSWORD_STRING}"
153
+
# The databases of parallel test workers, named after the test database with a numeric suffix.
154
+
${CLIENT_BINARY} -e "GRANT ALL PRIVILEGES ON \`${TEST_DB}\\_%\`.* TO '${TEST_USER}'@'%'"${HOST_STRING} -u"${USER}""${PASSWORD_STRING}"
153
155
{ set +ex; } 2> /dev/null # stop printing the commands
${CLIENT_BINARY} -e "CREATE DATABASE IF NOT EXISTS \`${TEST_DB}\`;"${HOST_STRING} -u"${USER}""${PASSWORD_STRING}"
160
162
${CLIENT_BINARY} -e "GRANT ALL ON \`${TEST_DB}\`.* TO '${TEST_USER}'@'%' IDENTIFIED BY '${TEST_PASSWORD}'"${HOST_STRING} -u"${USER}""${PASSWORD_STRING}"
161
163
${CLIENT_BINARY} -e "GRANT ALL ON \`${TEST_DB}_scaffold\`.* TO '${TEST_USER}'@'%' IDENTIFIED BY '${TEST_PASSWORD}'"${HOST_STRING} -u"${USER}""${PASSWORD_STRING}"
164
+
# The databases of parallel test workers, named after the test database with a numeric suffix.
165
+
${CLIENT_BINARY} -e "GRANT ALL ON \`${TEST_DB}\\_%\`.* TO '${TEST_USER}'@'%' IDENTIFIED BY '${TEST_PASSWORD}'"${HOST_STRING} -u"${USER}""${PASSWORD_STRING}"
162
166
{ set +ex; } 2> /dev/null # stop printing the commands
163
167
}
164
168
@@ -169,6 +173,8 @@ install_mariadb() {
169
173
${CLIENT_BINARY} -e "CREATE USER IF NOT EXISTS \`${TEST_USER}\`@'%' IDENTIFIED BY '${TEST_PASSWORD}'"${HOST_STRING} -u"${USER}""${PASSWORD_STRING}"
170
174
${CLIENT_BINARY} -e "GRANT ALL PRIVILEGES ON \`${TEST_DB}\`.* TO '${TEST_USER}'@'%'"${HOST_STRING} -u"${USER}""${PASSWORD_STRING}"
171
175
${CLIENT_BINARY} -e "GRANT ALL PRIVILEGES ON \`${TEST_DB}_scaffold\`.* TO '${TEST_USER}'@'%'"${HOST_STRING} -u"${USER}""${PASSWORD_STRING}"
176
+
# The databases of parallel test workers, named after the test database with a numeric suffix.
177
+
${CLIENT_BINARY} -e "GRANT ALL PRIVILEGES ON \`${TEST_DB}\\_%\`.* TO '${TEST_USER}'@'%'"${HOST_STRING} -u"${USER}""${PASSWORD_STRING}"
if [ -n"${PARALLEL}" ] && [ "${PARALLEL}"!="1" ];then
341
+
if! is_numeric "${PARALLEL}";then
342
+
echo"Warning: WP_CLI_TEST_PARALLEL is not a number of workers, running the scenarios one after the other.">&2
343
+
PARALLEL=""
344
+
elif [[ "${WP_CLI_TEST_COVERAGE}"=="true" ]];then
345
+
echo"Code coverage is collected, running the scenarios one after the other.">&2
346
+
PARALLEL=""
347
+
elif [ "${WP_CLI_TEST_DBTYPE-}"!="sqlite" ] &&!${DB_CLIENT}${HOST_STRING} --user="${USER}"${PASSWORD_ARG} --execute="CREATE DATABASE IF NOT EXISTS \`${DBNAME}_1\`; DROP DATABASE \`${DBNAME}_1\`;"2>/dev/null;then
348
+
echo"Warning: The test user cannot create the databases of parallel workers, running the scenarios one after the other.">&2
349
+
echo"Run 'composer prepare-tests' once to allow it.">&2
350
+
PARALLEL=""
351
+
fi
352
+
fi
353
+
354
+
if [ -n"${PARALLEL}" ] && [ "${PARALLEL}"!="1" ];then
0 commit comments