4teamwork/opengever.core — pull request #566 by jone (2014-09-22 07:06:17+00:00)
Title: Parallel tests with bin/mtest

The new script ``bin/mtest`` runs the tests in multiple processes; the original ``bin/test`` script is not touched.

The script creates multiple subprocesses to ``bin/test``, each running tests for a set of opengever subpackages, e.g.:
```
WORKER0: > bin/test -q --no-progress -m opengever.task -m opengever.document -m opengever.repository -m opengever.contact -m opengever.core
WORKER1: > bin/test -q --no-progress -m opengever.base -m opengever.inbox -m opengever.globalindex -m opengever.trash -m opengever.advancedsearch
WORKER2: > bin/test -q --no-progress -m opengever.dossier -m opengever.latex -m opengever.tabbedview -m opengever.sharing
WORKER3: > bin/test -q --no-progress -m opengever.mail -m opengever.tasktemplates -m opengever.setup -m opengever.journal
```

**Distribution**
The packages are distributed onto the available workers by sorting the packages by amount of test suites and then assigning the largest to the first worker, the second largest to the second worker etc. This should balance the workers and speed up everything.

**Output**
The script captures and reformats the output of the workers, reformats them and prints them to stdout. It adds prefixes on every line, indicating which process is printing. It also colorizes the output so that it is easily visible which blocks are from the same worker.

![bildschirmfoto 2014-09-22 um 08 49 15](https://cloud.githubusercontent.com/assets/7469/4352521/e1705448-4225-11e4-94c1-2ddb2cd9e6d4.png)

**Configuration**
- The environment variable ``MTEST_PROCESSORS`` defines the amount of workers, defaults to ``4`` (set to ``8`` globally on jenkins for optimal performance).
- The environment variable ``MTEST_NOCOLORS`` allows to disable colorization (disabled on jenkins).

**Jenkins**
The buildout configuration is updated so that on jenkins ``bin/mtest`` is used.

**Performance**
Local:
```
# Before
./bin/test 359.36s user 9.62s system 99% cpu 6:09.88 total
# After
bin/mtest 711.59s user 75.25s system 414% cpu 3:09.79 total
```

On Jenkins the bin/test time goes from 401s down to 126s.