Features/ Uniquely identify concurrent processes #23

merged 3 commits into from May 4, 2013


None yet
3 participants

dbaltas commented Feb 5, 2013

Allows phpunit to run with an extra environment variable, TEST_TOKEN
which is unique per running process.

Paratest attaches the TEST_TOKEN environment variable to the command.

TEST_TOKEN=1 phpunit file1
TEST_TOKEN=2 phpunit file2
TEST_TOKEN=3 phpunit file3

When a running process ends, the token is released to be acquired by the next process to run.

The test suite can use the value of the variable to ensure a unique resource (database, file system) for parallel processes .
In the application code (TestBootstrap)

        $testToken = getenv('TEST_TOKEN');
        if (is_numeric($testToken)) {
            $databaseName .= sprintf("%s", (int)$testToken+1);

brianium commented Feb 6, 2013

Very cool. Pulling now. I might want to spend a little time looking at this one. Definitely a cool feature, and I think it belongs in paratest. I want to keep an eye on the ExecutableTest base and the Runner as they grow. I should have some input for you tonight or tomorrow hopefully. Thanks again for your work!


dbaltas commented Feb 6, 2013

Here is the script we used to clone the test databases, and synchronize their schema on our ZF1.x codebase

Our test suite consisting of 13.000 tests dropped from 16 minutes to 4:10 (~75%).
We used 8 parallel processes.


giorgiosironi commented Feb 17, 2013

I think I could use the same mechanism for reuse_bootstrap. However, the TEST_TOKEN will be passed to the Worker process once at its startup.


giorgiosironi commented May 3, 2013

Have been using this code on our real world test suite and it works like a charm. +1 for me

@giorgiosironi giorgiosironi merged commit ef7ce73 into brianium:master May 4, 2013

1 check passed

default The Travis build passed

giorgiosironi commented May 4, 2013

Merged manually due to a conflict in ExecutableTest.


brianium commented May 9, 2013

This bit is pretty impressive. I think we might need to get a wiki going to demonstrate how this stuff can be leveraged.


giorgiosironi commented May 11, 2013

After my phpDay presentation I will paste some code from it in the wiki of the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment