Parallel test running with phpunit: "send" 2 different phpunit calls to different containers

Hi,

I want the simplest parallel test running I can think of:
I would like to have my phpunit data level tests run parallel with my selenium UI tests.
The good thing about it - I already use 2 different commands for executing each:

 #run tests
      - run:
          name: Run Unit tests
          command: |
            vendor/bin/phpunit tests/phpunit/ --coverage-php tests/coverage/phpunit.cov
            cp .circleci/uicodecoverage.php tests/
            vendor/bin/phpunit tests/selenium/
            vendor/bin/phpcov merge tests/coverage/ --clover tests/coverage/clover.xml
            rm tests/uicodecoverage.php
            rm -R -f tests/coverage/*.cov
            bash <(curl -s https://codecov.io/bash) -f tests/coverage/clover.xml

So I would only need to setup that calling vendor/bin/phpunit tests/phpunit/ --coverage-php tests/coverage/phpunit.cov is sent to container 1, and that vendor/bin/phpunit tests/selenium/ is sent to container 2.
However, after reading into quite everything I found about parallelism here, I didnt find any hint how to set this up - can someone point me in the right direction?

Best regards
Philipp

Since you have two fixed sets of tests, in your code above just change it to use a Bash conditional, such that:

  • $CIRCLE_NODE_INDEX == 0 - run one set of tests
  • $CIRCLE_NODE_INDEX == 1 - run the other set of tests
1 Like

So something like:

        cp .circleci/uicodecoverage.php tests/
        if [$CIRCLE_NODE_INDEX == 0]; then
            vendor/bin/phpunit tests/phpunit/ --coverage-php tests/coverage/phpunit.cov
        else 
            vendor/bin/phpunit tests/selenium/
        fi
        vendor/bin/phpcov merge tests/coverage/ --clover tests/coverage/clover.xml
        rm tests/uicodecoverage.php
        rm -R -f tests/coverage/*.cov
        bash <(curl -s https://codecov.io/bash) -f tests/coverage/clover.xml

? will try that

1 Like

Hi Phiipp. Please let us know if Jon’s suggestions worked for you. :slight_smile:

Hi there,
yes, indeed it succeeded. Luckily, my unit tests and my selenium UI tests take about the same time, so I run each on one container. This works:

        if [ $CIRCLE_NODE_INDEX = 0 ]; then
            vendor/bin/phpunit tests/phpunit/ --coverage-clover tests/coverage/phpunit.xml
            bash <(curl -s https://codecov.io/bash) -f tests/coverage/phpunit.xml
        fi
        if [ $CIRCLE_NODE_INDEX = 1 ] || [ $CIRLE_NODE_TOTALS = 1 ]; then
            vendor/bin/phpunit tests/selenium/
            vendor/bin/phpcov merge tests/coverage/ --clover tests/coverage/selenium.xml
        fi
2 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.