-
Notifications
You must be signed in to change notification settings - Fork 240
New run-tests.ts, making test runs more reliable
#1401
Conversation
This fixes `npm run tests:all` for me. Not the right solution but at least something until we find the true cause.
|
1778c7f shows how moving Workflow tests above End2End tests in However, it also makes tests run considerably slower – 30 minutes instead of 10 for I think we should clean up the testing environment before each "big" test suite. |
It's demonstrated on TemporaryDbTest that should fail if waiting is commented out from `run-tests.ts`.
7e3f172 to
c1a1fbb
Compare
|
c1a1fbb deals with another problem that @pavelevap frequently encounters – tests run before the Docker containers are fully started (WP + MySQL take around 20 seconds to start on my machine, can be longer depending on a specific device). The commit shows an approach where a waiting container is added to versionpress/docker-compose-tests.yml Lines 59 to 62 in c1a1fbb
versionpress/scripts/run-tests.ts Line 15 in c1a1fbb
Running the commit as it is with But when I comment out the waiting line in So that proves that the waiting container works. Note that on my machine, to make the test fail, it was necessary to start the MySQL from an entirely clean state – with the volume deleted, otherwise, it was too quick to start to demonstrate the issue. That's why the |
This will be resolved differently. Also, changing the order made tests run much slower (30 minutes instead of 10 on my machine). This reverts commit 1778c7f.
zeit/arg is used to parse arguments, which currently are: - `--help` - `--with-wordpress` (false by default which is why unit tests don't start anything) - `--testsuite` – an array of testsuites from phpunit.xml to run.
The script added a detection of whether all tests will be run and sets `--with-wordpress` accordingly.
|
The recent commits implemented The script has this "API" for now: TODO:
|
|
BTW I'm pretty happy with the test reliability now:
The |
In a typical docker-compose setup, WordPress and MySQL start at the same time and the WordPress container then implements a logic to wait for MySQL to start, see [here](https://github.com/docker-library/wordpress/blob/acd229d6d638566a3ccd921d20075182db9e1185/php7.2/apache/docker-entrypoint.sh#L255-L266). It "only" tries for 30 seconds, though, which is not enough on less powerful computers which leads to a confusing experience. See also docker-library/wordpress#392. This commit implements a solution where MySQL starts first, we await its availability and only then start the WordPress container. With this custmization, and with run-tests.ts in general, we don't really want services from `docker-compose-tests.yml` to be started manually so I added a big warning at the top of that file and removed all "links:" that would indicate that containers can start on their own – that's no longer true. Also, the waiting container is created by plain `docker run` inside run-tests.ts instead of being an empty "service" inside the YAML. I'm a bit torn on this so let's see...
For example, End2End or Workflow tests start WordPress, unit tests don't. As part of this, I simplified the run-tests script: - `--with-wordpress` cannot be specified manually, it is always inferred. - Only one `--testsuite` can be passed, not an array of them. KISS.
Quite a few things have been deleted as they no longer apply or are likely outdated.
`testing.md` now contains several smaller TODOs but the debugging information that I still think is valid is there.
Intead of a complicated manual invocation via `node -r node_modules/ts-node/register`, it is now recommended to run custom scripts via `npm run tests -- <parameters>`.
Examples added to testing.md
|
@pavelevap The PR is now ready for a review. Docs preview here. |
|
I'm getting consistent results between several machines now. 🎉 MacBook Pro with Docker DesktopMacBook Pro (2015) Tests took 11 minutes. Windows laptop with Docker DesktopDell XPS 13 9350 (2015) Tests took 18 minutes. (The CLI environment is using this MSYS2 setup.) Windows laptop with Docker ToolboxHP ProBook 650 G1 (2014) Tests took 37 minutes. I tried with both the default VM configuration (1GB RAM, 1 CPU) and an upgraded VM with 4GB RAM and 2 CPU but it didn't have any effect, the tests still took about 37 minutes. It's probably limited by the virtualization technology; the tests cannot utilize the more resources: Test outputOn all machines, the console output was this: Note: the above is omits the failing test with many empty lines, see #1400 (comment). |
run-tests.ts, making test runs more reliable







Issue: #1389
Issue: #1400
The main goal of this PR is to improve reliability of our test runs –
npm run tests:fullshould produce consistent results across operating systems and several runs on the same machine.Highlights:
scripts/run-tests.tsinstead of direct invocation of docker-compose and PHPUnit. This allows better control over how the tests run, which containers are started and in which order, there's proper waiting between them (c1a1fbb), etc. This resolves many confusing behaviors when the computer was too slow to start or something similar.Full TODO list:
scripts/run-tests.tsto orchestrate test runs.--testsuite Workflowshould start WP.tests:customscripts frompackage.json.testing.md.Fail immediately by default, flag to let them runI've decided against it for now.On Ctrl+C to the Node.js script, gracefully shut down containers.Postponed; the user has to clean up manually.node -r ts-node/register run-tests ...tonpm run tests -- ....Noted for followup PRs:
docker-compose -f docker-compose-tests.yml up -d wordpress-for-tests mysql-for-testsis a bit weird, review it.tests:cleanup?