Phpunit builds fail, but when i ssh in and run phpunit they work fine

I’ve tried all sorts of setups including phantomJs, selenium standalone server, and now using sauce connect to hit saucelabs. the builds work perfectly fine locally, but always time out / error when running on circle-ci. the WEIRD part is if I ssh in and run phpunit myself, it works perfectly fine. I cannot duplicate this ssh’ed in at all, they always rune fine. i’ve tried all sort of sleeps and timeout extensions to give everything as much time as needed. no luck

here is the setup:

failed build https://circleci.com/gh/acidjazz/basal/86

the actual error

1) Tests\Browser\LoginTest::testClientAdd
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http GET to /session/d18207b0747f4149a30ceb8c2fb7c73d/screenshot

Operation timed out after 120000 milliseconds with 0 bytes received

/home/ubuntu/basal/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:287
/home/ubuntu/basal/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:597
/home/ubuntu/basal/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:373
/home/ubuntu/basal/vendor/laravel/dusk/src/Browser.php:206
/home/ubuntu/basal/vendor/laravel/dusk/src/TestCase.php:158
/home/ubuntu/basal/vendor/laravel/framework/src/Illuminate/Support/Collection.php:244
/home/ubuntu/basal/vendor/laravel/dusk/src/TestCase.php:159
/home/ubuntu/basal/vendor/laravel/dusk/src/TestCase.php:92
/home/ubuntu/basal/tests/Browser/LoginTest.php:89

my circle.yml

machine:
  timezone:
    America/Los_Angeles
  php:
    version: 7.0.4
  environment:
    ENVIRONMENT: testing
    APP_ENV: testing
    APP_DEBUG: true
    APP_URL: http://127.0.0.1:8000

dependencies:
  pre:
    - pecl install mongodb
    - echo "extension=mongodb.so" > /opt/circleci/php/7.0.4/etc/conf.d/mongodb.ini
    - printf "\n" | pecl install yaml-2.0.0
    - echo "extension=yaml.so" > /opt/circleci/php/7.0.4/etc/conf.d/yaml.ini
    - composer install --no-interaction
    - npm i --prefix vendor/acidjazz/larpug/node/
    - wget https://saucelabs.com/downloads/sc-4.4.4-linux.tar.gz
    - tar -xzf sc-4.4.4-linux.tar.gz

test:
  override:
    - php ./artisan serve:
        background: true
    - cd sc-4.4.4-linux && ./bin/sc --user $SAUCE_USERNAME --api-key $SAUCE_ACCESS_KEY --readyfile ~/sauce_is_ready:
        background: true
    # Wait for tunnel to be ready
    - while [ ! -e ~/sauce_is_ready ]; do sleep 1; done
    - ./vendor/bin/phpunit
Curl error thrown for http GET to /session/d18207b0747f4149a30ceb8c2fb7c73d/screenshot

Are you logging these errors somewhere? If so, can you save them as an artifact and paste the output here? It would be helpful to see the full error that CURL is getting.

I’ve looked into some kind of logging flag to pass to curl from WebDriver, no look so far. Any idea why this works via SSH though?

There might be a race condition, or the tests are running “too fast”

Operation timed out after 120000 milliseconds with 0 bytes received

Is there a way to increase the timeout perhaps?

I tried increasing the timeouts in the webdriver and adding sleeps around each server start up to about 20 seconds each, no matter what I still timedout, immediately ssh’ed in, ran phpunit, and it was fine.

Did you manage to find a fix for this? I am receiving the exact same error, however it happens intermittently. I will run the build the first time and it will fail with the above error, I will then rebuild and it will work fine. This happens often enough to be annoying. SSH’ing in and running the builds will intermittently fail also.